XHTML1.0 vs XHTML 1.1

Hi all,

What’s the difference between the above standards?

Which should be used in webpages?

Thanks.

Kevin.

http://www.trap17.com/index.php/xhtml-1-1-vs-xhtml-1-0_t28982.html

XHTML 1.0 is a reformulation of HTML 4.01 as an application of XML.
XHTML 1.1 is a reformulation of XHTML 1.0 Strict using Modularization of XHTML.

XHTML 1.0 is just an application of XML which uses the same set of element names and attributes (i.e., semantics) as HTML 4.01. It comes in three different DTDs (Strict, Transitional, Frameset) just like HTML 4.01.

XHTML 1.1 uses a concept called Modularization of XHTML, which means that the definition is split into a number of modules, which you can combine in any combination. There’s something called XHTML Basic, for instance, which comprises just the essential modules for simple documents. XHTML 1.1 uses all modules (including a module for Ruby annotations that isn’t part of any XHTML 1.0 DTD).

For most webpages, the logical choice is still HTML 4.01 Strict.

Why HTML? Because a large majority of users still use Internet Explorer, which does not support XHTML at all. Although you may use XHTML markup and serve it as text/html so that IE will accept the document, it’s pointless since you cannot use any advantage that XHTML may have over HTML.

Why Strict? Because the Strict DTD enforces the separation of structure and presentation more than the Transitional DTD (which is mean to be used during a transitional phase when you convert old pre-HTML4 documents to a modern form).

If you absolutely have to write a few scattered ‘/’ characters in your markup to feel manly (or whatever), or if you belong to the .0001% of Web authors who really need XHTML and can afford to ignore IE users, you should probably stick to XHTML 1.0 Strict.

If you serve the document as text/html, don’t even think about using XHTML 1.1. It is not backwards-compatible with HTML and should not be served as text/html.

Sticking this thread so hopefully we don’t have any more like it :slight_smile:

Off Topic:

Well, you can hope but I am sure the question will still get asked several thousand times.

just let me live in my fantasy world okay? :slight_smile:

Great thread, thanks for the post Autistic :slight_smile:

Right, if this thread is going to be sticky, I’ll add another thing that seems to confuse many beginners. :slight_smile:

What is required for a document to be treated like XHTML?

[list=1][]A content type that says it’s an application of XML.
[
]An XML namespace equal to ‘http://www.w3.org/1999/xhtml’.[/list]

Content Type
The content type (a.k.a. media type or MIME type) must be sent by the server in the Content-Type HTTP header. You cannot change the content type with a META element, since the user agent needs to know what the document is before starting to parse it. There are three MIME types that will do this for XHTML:

[list][]application/xhtml+xml
[
]application/xml
[*]text/xml[/list]
Using text/xml is not recommended, because there are some serious encoding issues with that MIME type. The recommended one is application/xhtml+xml.

Arguably, the server should not send any character encoding information in the Content-Type header, since X(HT)ML is meant to be a self-describing format where the encoding should be specified in the XML declaration. Thus the server should only send this:

Content-Type: application/xhtml+xml

and the document should start with something like this:

<?xml version="1.0" encoding="utf-8"?>

Note that if you use a MIME type of text/xml, the encoding will be US-ASCII unless the server sends encoding information in the Content-Type header. You cannot override it with an XML declaration (and, of course, not with a silly <meta/> element).

XML Namespace
The content type only tells the user agent that the document is an application of XML. Even if the MIME type is application/xhtml+xml, user agents don’t know that it is, in fact, XHTML.

The thing that tells them that is the ‘xmlns’ attribute of the document’s root element:

<html xmlns="http&#58;//www.w3.org/1999/xhtml" xml:lang="en">

If you don’t use this exact namespace URI, the document is not an XHTML document; it’s general XML. That will cause some interesting effects in how the page is rendered… It will also cause certain elements to stop working, because the semantics is lost.

What about DOCTYPE?
Didn’t I forget something in my list above? Surely, it’s the doctype declaration that makes it XHTML? This techie stuff about HTTP headers and XML namespaces is just a smoke screen, isn’t it? 'Fraid not.

The doctype declaration doesn’t matter at all, as far as browsers are concerned. Browsers that support XHTML will not do doctype switching when the document is served as an application of XML. At least not to my knowledge. They will use their strict rendering mode.

The doctype is only used when you’re validating your document. A validator must know with which flavour of XHTML you’re claiming compliance. Browsers don’t care.

The Doctype however matters with regard to referencing which syntax elements and attributes you are allowed to legally use within a strictly conforming XHTML document a Validating XML Parser may analyse it. A real XHTML UA does not necessary have to support client-side scripting either.

Great post Tommy and well stated !

Nadia

True, but an XML parser does not have to read the DTD or schema definition, and AFAIK none does.

So you could use a ‘target’ attribute for a link even with a Strict doctype, and it would work in the browser even though it’s not valid. The only validation errors that are caught are well-formedness errors, and those are caught with a vengeance! :slight_smile:

You are thinking browsers Tommy I meant Validating XML Processors and some check for Valid XHTML but as you say most browsers just use Well-formedness Parsers.

So if my documents starts like this:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

Is there something wrong?

That’s called fake xhtml. When using real xhtml you have to put the ?xml version=“1.0” encoding=“utf-8”?> at the top of your document as serve up the proper mime type as well. But you can’t do that yet because IE doesn’t support it.

No. The XML declaration is optional if you use utf-8 (or a subset of utf-8, such as us-ascii) or utf-16, or if you have specified the encoding with HTTP.

Okay, I’ve got one that says it is “fake” and another says that there is nothing wrong…
Who is right here?

Stymiee: So if I use the proper xml declaration to serve the proper mime type at the top of the page IE users wont be able to view the page?

Hello

the browser that is used most, 80%~85% ? is not playing ball :slight_smile: :lol:

If you serve it as text/html then it’s indeed “fake” XHTML; the browser will interpretet as if it was HTML. If you serve it as XML then it’s “true” XHTML. You didn’t say which it was, you only asked if there was anything wrong without the XML declaration.

Simon is right, the XML declaration is optional under certain circumstances. The markup fragment you show seems correct, but we can’t say whether it’s ‘right’ or ‘wrong’ without knowing the MIME type. If it’s application/xhtml+xml (or similar) it’s ‘right’. If it’s text/html it’s ‘wrong’ (i.e., not XHTML).

The XML declaration has nothing to do with that. It’s the application/xhtml+xml MIME type that IE doesn’t support.

You may serve it as application/xml, which IE supports. It will then be treated as XML. However, IE does not understand the XHTML namespace, so it will not be treated as XHTML, but as generic XML.

In otherwords the User Agent or Server may under certain circumstances determine the outcome as to whether it ends up being processed as the genuine article.