1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

A question on some particular XHTML related code

Discussion in 'HTML & Website Design' started by tayiper, May 10, 2006.

  1. #1
    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
     
    tayiper, May 10, 2006 IP
  2. sawz

    sawz Prominent Member

    Messages:
    8,225
    Likes Received:
    808
    Best Answers:
    0
    Trophy Points:
    360
    #2
    the following url may explain it too you:

    http://www.developerfusion.co.uk/show/1704/9/
     
    sawz, May 10, 2006 IP
  3. tayiper

    tayiper Active Member

    Messages:
    421
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    78
    #3
    Thanks much for a quick reply, I am just loading the page ...


    tayiper
     
    tayiper, May 10, 2006 IP
  4. tayiper

    tayiper Active Member

    Messages:
    421
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    78
    #4
    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
     
    tayiper, May 11, 2006 IP
  5. sawz

    sawz Prominent Member

    Messages:
    8,225
    Likes Received:
    808
    Best Answers:
    0
    Trophy Points:
    360
    #5
    i really couldn't give a specific recommendation. your using windows-1250 i see:)
     
    sawz, May 11, 2006 IP
  6. kk5st

    kk5st Prominent Member

    Messages:
    3,497
    Likes Received:
    376
    Best Answers:
    29
    Trophy Points:
    335
    #6
    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.
     
    kk5st, May 12, 2006 IP
  7. tayiper

    tayiper Active Member

    Messages:
    421
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    78
    #7
    Thanks much kk5st for a very educative reply ...


    tayiper
     
    tayiper, May 12, 2006 IP