<!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>
XHTML 1.0 STRICT Page Structure
Chris Coyier
on
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.
I don’t split doctype into 2 lines, it works.
Excellent ,good,
It isn’t necessary to split the doctype into 2 lines, it’s for readability sake.
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).
XHTML1 Strict should not use “text/html”, instead it should use:
<meta http-equiv=”Content-Type” content=”application/xhtml+xml; charset=utf-8″ />
According to the W3C, “The text/html is primarily for HTML and NOT for XHTML.” And, “XHTML documents served as ‘text/html’ will not be processed as XML.”
Also, The ‘application/xhtml+xml’ media type [RFC3236] is the primary media type for XHTML Family documents.
Simply put, text/html 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/xhtml+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.
“This is why all “proper” XHTML 1.0 Strict examples still tell the page is to be handled as text/html” is incorrect, because it DOES prevent browsers from dealing the page information as XML, since it forces the browsers to treat the page as HTML-ish tag soup.
It’s not only “against the standard of course”, but it’s simply broken. Also, it obfuscates the content itself.
If “practicality weights over technical perfectness”, then simply don’t use XHTML and use HTML5 instead.
**just do it dude **
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”;
/* */