Hey all, I am interested, what is the purpose of the code below, used on some of the XHTML sites ?? The code in question (before the DOCTYPE declaration): <?xml version="1.0" encoding="utf-8"?> Code (markup): Then I am curious, could I too add this chunk of code on my sites (or maybe this is even recommended), and will they still be a valid XHTML code by W3C ?? And if it is so, should I change anything in my site's source, since I have this: <meta http-equiv="content-type" content="text/html; charset=windows-1250> in my meta-data ... So in the end, it would look like: <?xml version="1.0" encoding="utf-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> Code (markup): tayiper
OK, then one more question; hopefully a final one ... Which particular character-encoding do you recommend me to use, i.e. which one is more "universal" or "compatible" etc.: the windows-1250 or the windows-1252 one ?? tayiper
The xml declaration, sometimes called xml prolog, should only be used on xml documents. Even then, it is optional as long as you're using xml 1.0 and utf-8. No html document or xhtml document delivered as text/html should contain the declaration. It does no good and can cause harm. IE's quirk mode is triggered by anything coming before a complete DTD, even comments. In quirk mode, IE follows even fewer css rules and gets the ones it does follow even more wrong. The character set encoding is trickier. Your editor may use one set, the server may declare a set, and your own meta element may name one. If it's there, the server header rules. That's a server configuration issue. The problem arises when there is conflict between the editor and server header/meta charset. If you use a MSFT editor, you're courting trouble on any charset other than ASCII. The windows-1252 or 1250 use illegal entity coding[1]. As long as you declare that set in your meta tag, and the server doesn't contradict it (which it will if it declares any charset), you're ok. MS editors tend to add BOMs (byte order mark) to unicode or utf-8 encodings. It's not needed for utf-8 since utf-8 and utf-16 are self describing. As mentioned above, that will cause IE to go into quirk mode, a Bad Thing®. So, save your documents as ASCII, iso-8859-x (AKA latin-x) or utf-8 (without a BOM). Be sure the meta tag correctly reflects the charset you're actually using. cheers, gary [1] Windows-xxxx charsets use entities (character encodings) in the 128–159 range. That and 0–31 are reserved by international standards for control characters. There is no telling how a browser expecting ASCII or utf-8 will render those characters.