Where can I find sample XHTML 5 pages? I mainly want to know if it is possible to mix and match XHTML 5 with other XML languages just like XHTML 1 or not. For example is something like this valid in XHTML 5?
<!DOCTYPE html PUBLIC "WHAT SHOULD BE HERE?"
"WHAT SHOULD BE HERE?">
<html xmlns="WHAT SHOULD BE HERE?"
xmlns:ui="http://java.sun.com/jsf/facelets">
<head>
<title><ui:insert name="title">Default title</ui:insert></title>
<link rel="stylesheet" type="text/css" href="./css/main.css"/>
</head>
<body>
<div id="header">
<ui:insert name="header">
<ui:include src="header.xhtml"/>
</ui:insert>
</div>
<div id="left">
<ui:insert name="navigation" >
<ui:include src="navigation.xhtml"/>
</ui:insert>
</div>
<div id="center">
<br />
<span class="titleText"> <ui:insert name="title" /> </span>
<hr />
<ui:insert name="content">
<div>开发者_Python百科
<ui:include src="content.xhtml"/>
</div>
</ui:insert>
</div>
<div id="right">
<ui:insert name="news">
<ui:include src="news.xhtml"/>
</ui:insert>
</div>
<div id="footer">
<ui:insert name="footer">
<ui:include src="footer.xhtml"/>
</ui:insert>
</div>
</body>
</html>
Thanks in advance.
You don't need a doctype at all. They are not designed to cope with namespaces and don't serve any useful purpose in XML. (In HTML, they are necessary to get into standards mode.) If you really insist on having one, for whatever reason, use simply <!DOCTYPE html>
.
As for the namespace:
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets">
as you are already using, I assume.
As you see, there is no information about the version you're using. That's because you don't need it. For validation, you can pick your target in the UI, and browsers have never looked at versions. That is, in browsers, there is no such thing as HTML3.2 or HTML4.01 or HTML5, just "HTML", and no XHTML1.0, XHTML1.1 or XHTML5, only "XHTML". Today, those consist mainly of HTML4.01/XHTML1.0 and some parts of HTML5, as well as some proprietary parts (though HTML5 has specified most of these).
This is a very good question, covering outstanding issues the W3C is still working on as of late 2012:
Concerning the DOCTYPE question, there could be new developments on the DOCTYPE matter: as of Nov. 12th, 2012, the HTML5 Latest Editor's Draft states, concerning the HTML syntax, in section "8.1.1 The DOCTYPE", that:
- "A DOCTYPE is a required preamble [...]" =>
<!DOCTYPE html>
- "For the purposes of HTML generators that cannot output HTML markup with [that] short DOCTYPE, a DOCTYPE legacy string may be inserted [...]" =>
<!DOCTYPE html SYSTEM "about:legacy-compat">
can be used if absolutely required (e.g. by an XML generator) - "To help authors transition from HTML4 and XHTML1, an obsolete permitted DOCTYPE string can be inserted [...]" => e.g.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
(or any of 5 others, see below)
To my understanding:
- all 3 forms hold exactly the same meaning : "this doc is HTML5", no matter what the specific, legal, legacy PUBLIC doctype being used for backward-compatibility reasons
- and using one of them is required (i.e. use the first one, unless you have really good reasons not to)
Unless last-minute edits occurs, this should make it into the HTML5 W3C Candidate Recommendation 08 November 2012.
The XHTML syntax remains unchanged on that matter: "XML documents may contain a DOCTYPE if desired, but this is not required to conform to this specification."
To sum it up, starting Nov. 8th, 2012, any of the following would be valid:
<!DOCTYPE html>
<!DOCTYPE html SYSTEM "about:legacy-compat">
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0//EN">
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
And:
- any other doctype invalid,
- no doctype at all, invalid HTML
- and no doctype still an option for XML...
Your best bet is probably the HTML5 specification's section on XHTML, which mostly calls out to the XML 1.0 5th edition spec and the namespaces spec. As it says there, there's no defined DOCTYPE for HTML5 in XML, which is the answer to the DOCTYPE part of your question. It does specifically mention intermixing HTML5 with other content in XML documents, so that should be the answer to that part of your question.
For example is something like this valid in XHTML 5?
No, and you couldn't do it with XHTML 1 either. Once you start doing FOO + BAR documents, they are not valid FOO or valid BAR, just some combination of the two (which may conform to a DTD and thus be valid FOO + BAR)
<!DOCTYPE html PUBLIC "WHAT SHOULD BE HERE?"
"WHAT SHOULD BE HERE?">
A custom DTD that describes the combination of markup languages you are using.
When mixing namespaces you are usually better off forgetting about DTDs. It isn't going to be HTML compatible anyway, so text/html
is out of the question
<html xmlns="WHAT SHOULD BE HERE?"
xmlns:ui="http://java.sun.com/jsf/facelets">
The XHTML namespace has not changed. This is the same as every other version of XHTML.
I'm afraid there is no such thing as XHTML5.
You can have either real XHTML, with one of the classic XHTML DOCTYPEs (see other answers), or you can put in the <!DOCTYPE html>
one, and then it mostly validates, but then it's no longer fully XHTML. It will only work if you treat it as HTML.
For instance, this file
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head><title>test</title></head>
<body><p> </p></body>
</html>
will only work if you give it a .html
extension. With .xhtml
, no way.
You may think that saving as .html
is no big deal, but then it's HTML, regardless of what the contents of the file say. Then you can just as well throw away the XML declaration and the xmlns attribute and all other XHTML features.
精彩评论