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. User Avatar
    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. User Avatar
    elandy2009
    Permalink to comment#

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

  3. User Avatar
    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. User Avatar
    djdaniel
    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.

    • User Avatar
      Merri
      Permalink to comment#

      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.

  5. User Avatar
    jerome
    Permalink to comment#

    **just do it dude **

  6. User Avatar
    Jeanna
    Permalink to comment#

    This is a template I use in my JavaScript class where my instructor requires our assignments to be in XHTML STRICT-1 format. It has sections for CSS styling, Javascript code and Html markup. The CDATA is reuired to validate in HTML allowing the Javascript to be hidden when validating HTML. Thank you for posting yours. Here is mine:

    Blank Starter Code

    “use strict”;
    /* */

    /* css code here */

    “use strict”;
    /* */

Submit a Comment

Posting Code

You may write comments in Markdown. This makes code easy to post, as you can write inline code like `<div>this</div>` or multiline blocks of code in triple backtick fences (```) with double new lines before and after.

Code of Conduct

Absolutely anyone is welcome to submit a comment here. But not all comments will be posted. Think of it like writing a letter to the editor. All submitted comments will be read, but not all published. Published comments will be on-topic, helpful, and further the discussion or debate.

Want to tell us something privately?

Feel free to use our contact form. That's a great place to let us know about typos or anything off-topic.

icon-anchoricon-closeicon-emailicon-linkicon-logo-staricon-menuicon-nav-guideicon-searchicon-staricon-tag