Where can I find sample XHTML5 source codes? - html

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>
<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.

Related

Xhtml validator error "not reserved name"

I'm new to XHTML and I keep getting this error and can't find the solution anywhere.
Here's the error:
error.png
Here's my code:
<!DOCTYPE html public "-//project//test.xhtml">
<html>
<head>
<title>Tools</title>
<link href="oof.css" rel="stylesheet"type="text/css">
</head>
<body>
<div class="page">
<!DOCTYPE html public "-//project//test.xhtml"> is not an XHTML Doctype.
The specific error you get is because an identifier has to be PUBLIC or SYSTEM and it is case sensitive.
The Doctype needs to reference the DTD you are validating against, not an XHTML document.
Most XHTML documents will use this Doctype:
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
However, there is little point in using XHTML 1.0 in 2018. You would probably be better off using HTML 5 instead.
If you are using the XML serialisation of HTML 5, then you wouldn't use a Doctype at all.
Most people don't get any benefit from using XML though, and would be better off writing HTML instead. That uses the Doctype:
<!DOCTYPE html>
… and then only for historical reasons to trigger Standards mode in browsers.
You have a lot of errors in your syntax.
LINK tag is a self closing tag.
DOCTYPE html public "...." defines some info. Read about it here
Every opening tag has a closing tag
Here's what it should look like
<!DOCTYPE html public "-//project//test.xhtml">
<html>
<head>
<title>Tools</title>
<link href="oof.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div class="page"></div>
</body>
</html>

W3 validator validates XHTML page but now page is empty

So, I wanted to be strict on me and took one of HTML5 pages and validated it as XHTML Strict -- all the way.
Fixed every error reading the very helpful error messages. Now the entire page is fully XHTML compliant. But the page shows only the DIVS containing the ads. The main DIV containing the page matter is gone, haha!
Here's the page for your enjoyment:
http://mypollingcenter.com/charts1.htm
Well, I apologize. The problem was that in my over-zealousness, I changed
this line:
<script src="../avazyabadu/kramaanukrama.js" type="text/javascript"></script>
to this:
<script src="../avazyabadu/kramaanukrama.js" type="text/javascript"/>
Empty tag/element rule, you know.
So, the validator took the whole thing as JavaScript, maybe?
Lessons I learned:
That JavaScript external file reference is an exception to the XHTML/XML rule. Keep the closing tag.
The “space before slash” rule is no more with XHTML.
Mark up fully compliant with strict XHTML validate as HTML5, provided you switch headings as below.
XHTML does not need character set declaration if your page is in UTF-8
Use this Validator (Not this one)
XHTML top lines:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
HTML top lines:
<!DOCTYPE html>
<html lang="en-US">
<head>
<meta charset="utf-8">

Is it OK to use a self closing DIV tag? [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Are self-closing tags valid in HTML5?
For example:
<div id="myDiv" />
Something would then be done to populate this div using Javascript.
Is this valid HTML?
No. HTML 4.x doesn't have any concept of self closing tags.
It is valid in XHTML.
Div's are not valid self closing tags. To have an empty div it would be better to do this:
<div id="myDiv"></div>
According to the XML declaration and the XHTML 1.0 and 1.1 document definitions, this is fine: the null-end tag (>) may be used when immediately following the null-end start tag closer (/), and your code is equivalent to <div id="myDiv"></div>.
It's a different matter entirely whether any particular consumer will be able to process this correctly.
The SGML declaration used by HTML 4.01 allows tag shortening, but it has a different syntax for the null-end tags; there you can write <div id="abc"/this is a non-empty div/. Again, mileage may vary as for browser support. (My money is on "none".)
Future versions of HTML (HTML5? if that name is still alive) are no longer implemented as SGML languages, and therefore they simply allow what they say they do, without recourse to a formal grammar.
I ran these two blocks of code through the W3C validator. Copy and paste the code into the input under the Validate by Direct Input tab to see the results for yourself.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>title</title>
<meta http-equiv="content-type" content="text/html;charset=UTF-8" >
</head>
<body><div id="Mydiv" /></body>
</html>
The code block with Doctype of transitional HTML 4.01 failed the validation process.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
<head>
<title>Test</title>
<meta http-equiv="content-type" content="text/html;charset=UTF-8" />
</head>
<body><div id="Mydiv" /></body>
</html>
When I added the XHTML 1.0 transitional doctype, changed the meta tag to a self closing tag, and added in the html xmlns line, the validation passed.
So to answer the first half of your question, it is valid HTML under the XHTML 1.0 Transitional doctype. Whether or not you can use javascript to properly populate it, I am not sure.
Self Closing Tags in XHTML as implemented by browsers:
What are all the valid self-closing elements in XHTML (as implemented by the major browsers)?
Self Closing tags in html5:
Are (non-void) self-closing tags valid in HTML5?
No, it's valid XML (not HTML), and as far as I know, will only be accepted if the document is send with an application/xml mimetype.
However, it may work with XHTML, and the XHTML Doctype declaration.

Html validation error for property attribute

I am using few facebook social plugins and I am using the meta header. When validating the page, the W3C validator is throwing the error -> "Error: there is no attribute "property".
I am using the XHTML Transitional doctype - <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
Pls Suggest if I have to change the doctype to something else.
Facebook's plugins use Open Graph, which is built on RDFa. It's RDFa that adds the property attribute to elements. Without this addition, plain HTML has no such attribute. (If you ask me, it's a strange design to add a new attribute without namespacing it, and to re-use half of a <meta> tag. But no-one did.)
To validate XHTML-with-RDFa, you'll need the DOCTYPE:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN" "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd">
This means you will have to be writing valid XHTML 1.1. More
In order for a document to claim that it is a conforming HTML+RDFa document, it must provide the facilities described as mandatory in this section. The document conformance criteria are listed below, of which only a subset are mandatory:
All document conformance requirements stated as mandatory in the HTML5 specification must be met.
There should be a version attribute on the html element. The value of the version attribute should be HTML+RDFa 1.0 if the document is a non-XML mode document, or XHTML+RDFa 1.0 if the document is a XML mode document.
There may be a link element contained in the head element that contains profile for the the rel attribute and http://www.w3.org/1999/xhtml/vocab for the href attribute.
Example:
<html version="HTML+RDFa 1.1" lang="en">
<head>
<title>Example Document</title>
</head>
<body>
<p>Moved to example.org.</p>
</body>
</html>
As Open Graph suggests, if you're using HTML5, you're better off just using a prefix attribute like this:
<!doctype html>
<html prefix="og: http://ogp.me/ns#">
<head>
<title>HTML5 site</title>
<meta property="og:title" content="The Rock" />
</head>
<body>
</body>
</html>
You can leave the doctype as is and it will validate.
This approach has also been recommended by an Open Graph developer.

DOCTYPE tag problem

is it possible to use DOCTYPE tag in line 2 or 3 or ... and css works good ? (not line 1)
tag :
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
Yes. As long as it comes before your <html> tag, you should be fine. This might happen, for instance, if you put an XML declaration above it. The xml declaration, however, must occur at the very beginning of the file.
Example:
<?xml version='1.0' charset='utf-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>This is an example</title>
</head>
<body>
<h1>This is an example</h1>
<p>
You might even put an xml stylesheet declaration up above your
DTD declaration, which would look like this:
<code><?xml-stylesheet type="text/xsl" href="transform.xsl"?></code>
</p>
<p>But you still can't put any HTML above your DOCTYPE. Sorry.</p>
</body>
</html>
Seems like you are very persistent about doing strange things with your doctype. It's best you always use it AND put it on the first line of your document. If you go arround the web you'll find that almost every website has it like that.
Is there a reason why you don't want to do so?
IE6 will fall into quirks mode if you put anything (including an XML declaration) before the Doctype. So - "no".
Most browsers will fall into quirks mode (AFAIK) if any content appears before it. Don't use hosts who prevent you from using valid markup.
by standards, the DOCTYPE should be the first line. why would you not want to put it there anyways?