SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    monitormensch oerdec's Avatar
    Join Date
    Sep 2004
    Location
    Hamburg
    Posts
    706
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    xhtml: why charset twice?

    Hi,

    in xhtml I can write the XML declaration at the beginning of the document. Thereīs the encoding attribute for it, but there is no obligation to use it.

    OK, then thereīs the meta tag Content-Type which can contain the same as the xml declaration.

    Please tell me why...
    HTML Code:
    <?xml version="1.0" encoding="UTF-8" ?>
    ...
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    oerdec

  2. #2
    SitePoint Addict
    Join Date
    Nov 2003
    Location
    Malmoe, Sweden
    Posts
    265
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    When using XHTML the 'right' way (serving it as application/xhtml+xml etc.) you donīt have to use the meta[http-equiv='Content-Type'] element. The encoding attribute in the XML-prolog supersedes the information in the meta element and the Content-Type HTTP header sent by the server supersedes the encoding attribute in the XML prolog. If the browser has implemented HTTP correct that is. The encoding attribute and the information in the meta element is there mainly to be used when (and if) the user saves the document to her/his local computer to use later.

    This is not a just-html-question as you have to know the basics of HTTP and how web applications (and homepages) work (client/server etc.). As the web matures different technologies become more dependant upon each other and the learning curve will have slightly more slope then in the dawn of HTML.

    A possible scenario could be that the document author puts in the meta element as used to and that the server parses this and removes it at the same time it sets the Content-Type HTTP header and serves the document as that content type. But this is only a fictitious scenario. In reality the server only looks at the file suffix to set the Content-Type. It would probably be considered to 'expensive' to parse static documents like this.

    You can with a little help from Google find tons of information and sometimes very feverish discussions on this subject.

  3. #3
    monitormensch oerdec's Avatar
    Join Date
    Sep 2004
    Location
    Hamburg
    Posts
    706
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    OK, thanks for your large reply. Iīm very interested in this stuff and will look for more information. But I must say itīs very abstract for me. I hope to find a good intro in HTTP and related things to understand all that.

  4. #4
    Robert Wellock silver trophybronze trophy xhtmlcoder's Avatar
    Join Date
    Apr 2002
    Location
    A Maze of Twisty Little Passages
    Posts
    6,316
    Mentioned
    60 Post(s)
    Tagged
    0 Thread(s)
    It's extremely sensible to use: <?xml version="1.0" encoding="UTF-8"?>


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •