Artemis wrote:
I'm confused lol. My personal site is XHTML and I don't get any popup box when viewing in IE.

That is because the MIME type sent in the HTTP Content-Type header would be set to text/html. As has been discussed in this thread, the correct MIME type is application/xhtml+xml, but because IE does not recognise that, it offers the user the choice of what to do with the file (save or open with another application).

What is this <?xml?> used for? Why would the average personal site need it? If you could explain in "beginner speak", I would greatly appreciate it :)

The XML declaration is supposed to be used to define the version of XML being used (not to be confused with the actual markup language version number, as in XHTML 1.0 or XHTML 1.1), the character encoding of the file and whether or not the it's a standalone document (but I won't go into the details about the standalone attribute, it's rarely needed).

The syntax looks like the following and, when present, must occur on the first line of the file with no whitespace or other text before it (except maybe a UTF-8, -16 or -32 Byte Order Mark (BOM))

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

The version number refers to the XML version. There is currently only XML 1.0 and XML 1.1. Most XML that people write (including XHTML, MathML, SVG, etc.) is XML 1.0. There are significant differences between 1.0 and 1.1, but I won't go into detail here. Basically, unless you have a specific need to use XML 1.1, then use 1.0.

Be aware that an XML 1.0 parser that was not built for XML 1.1 as well, will fail with a well-formedness error if version="1.1" is encountered in the declaration. For XML 1.0, the XML declaration is optional.

The encoding determines the actual character encoding of the file. This can be any encoding name you like, preferably one defined by IANA.

The encoding attribute may be omitted, and in the absence of such information from a higher level protocol (e.g. the HTTP Content-Type header), the default for XML is UTF-8 or UTF-16. XML user agents will thus attempt to use either of those, determined by the presence or absence of the BOM.

The BOM is a essentially special Unicode character (U+FEFF) used for determining the particular UTF encoding, based on how the character itself is actually encoded within the file.

There is also a standalone attribute that can be set to "yes" or "no", but as I said I won't go into the details of what it means, it's quite confusing and you normally just leave it out.

Lastly, it is important that the version and encoding attributes appear in that specific order. It is not well-formed to write this:

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

As I said, the encoding attribute may be omitted, if the encoding is UTF-8 or UTF-16 (or if it is specified in a higher level protocol), so this is well-formed:

<?xml version="1.0"?>

If you are using XHTML and serving it as text/html, it's best to leave it out because anything before the DOCTYPE declaration will trigger quirks mode in IE, which is basically a mode that uses intentionally buggy, backwards compatible parsing and rendering behaviour reversed engineered from obsolete 4.x era (and earlier) browsers.

--
Lachlan Hunt
http://lachy.id.au/
******************************************************
The discussion list for  http://webstandardsgroup.org/

See http://webstandardsgroup.org/mail/guidelines.cfm
for some hints on posting to the list & getting help
******************************************************

Reply via email to