Grow your CSS skills. Land your dream job.

Last updated on:

XHTML 1.0 STRICT Page Structure

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

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

<head>
       <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
       <title>Page Title</title>
       <link rel="stylesheet" href="style.css" type="text/css" media="screen" charset="utf-8"/>
</head>

<body>

</body>

</html>

Comments

  1. abajan
    Permalink to comment#

    Is it necessary to split the doctype into 2 lines or is that just for readability sake?

    Which character set is more recommended – utf-8 or ISO-8859-1?

    Shouldn’t there be a space before the last slashes (/) in lines 7 and 9 to accommodate older browsers?

    Thanks.

  2. elandy2009
    Permalink to comment#

    It isn’t necessary to split the doctype into 2 lines, it’s for readability sake.

  3. H5N1
    Permalink to comment#

    1 – If the Accept header explicitly contains application/xhtml+xml (with either no “q” parameter or a positive “q” value) deliver the document using that media type. (http://www.w3.org/TR/xhtml-media-types/#media-types)
    so

    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

    should be

    <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8" />

    2 – For back-compatibility issues is reccommended to left a space before the last slash closing elements.

    3 – The XML Prolog is optional, but according to XML specifications should be there. (XHTML is HTML + XML).

  4. On of my favorite structures in HTML.

  5. Permalink to comment#

    XHTML1 Strict should not use “text&#047html”, instead it should use:
    <meta http-equiv=”Content-Type” content=”application&#047xhtml+xml; charset=utf-8″ &#047>

    According to the W3C, “The text&#047html is primarily for HTML and NOT for XHTML.” And, “XHTML documents served as ‘text&#047html’ will not be processed as XML.”

    Also, The ‘application&#047xhtml+xml’ media type [RFC3236] is the primary media type for XHTML Family documents.

    Simply put, text&#047html is not valid for XHTML strict documents. It is however valid for XHTML Transitional documents that must be able to support aspects of both HTML 4.01 and XHTML 1.0 respectively. Only the “Strict” form with a media type of “application&#047xhtml+xml” is true XHTML markup.

    • text/html is used for legacy reasons: old browsers tend to go rather insane when they treat XHTML as XML. Having ANY error on the page will prevent displaying the page which is a very bad thing: errors come and go on live sites, it is hard to have perfect code all of the time. Also XML used to require the whole page to be loaded before doing any render which could cause seconds of waiting before user could see the page (in case the page was big or the connection slow).

      This is why all “proper” XHTML 1.0 Strict examples still tell the page is to be handled as text/html – it doesn’t prevent any XML loader from dealing the page information as XML but all browsers play nice with it. It is against the standard of course, but sometimes practicality weights over technical perfectness.

      Of course these days HTML5 is very much the way to go unless you know you really need the XML strictness. You can write HTML5 in XHTML compatible syntax just fine so there really isn’t that many reasons to use XHTML. Probably 99% of new sites are better off using HTML5.

  6. **just do it dude **

Leave a Comment

Current day month ye@r *

*May or may not contain any actual "CSS" or "Tricks".