|
Posted by Andy Dingley on 02/04/06 15:27
On Fri, 03 Feb 2006 21:20:10 GMT, John Salerno
<johnjsal@NOSPAMgmail.com> wrote:
> > <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
>Thanks guys, seems simple enough! But should there be anything
>additional in the html tag? Or is that other stuff just XHTML extras?
XML extras really. This is why they're one of the few changes from HTML
4.01 -> XHTML. XHTML never really adds anything new, it just
reformulates HTML 4.01 in XML
xmlns="http://www.w3.org/1999/xhtml"
is a "namespace", as described here
http://www.w3.org/TR/REC-xml-names/
Arjun might pop up to explain why namespaces were badly designed, but
they are a vaulable feature of XML (maybe they were done badly, but
they're still useful).
Namespaces do a couple of things - they're an alternative to a doctype
and can be used to refer to an XML Schema instead. Secondly they're an
easy way to include elements from multiple schemas, so that you can very
easily embed Dublin Core or SVG elements into your HTML in a valid and
easily processed manner.
Sadly namespaces are an XML feature, definitly not SGML. So for
"Appendix C" XHTML, they are of no use whatsoever. They don't hurt
anything when used like this, but neither are they visible to web agents
that are receiving XHTML labelled as text/html.
You should always include the xhtml default namespace in an XHTML
document, whether it's Appendix C or not. But if you take namespaces
further and try to include namespaced elements, then you're no longer
looking like vaguely valid HTML and you've stepped ouside Appendix C.
Things may start to break at this point!
It's maybe worth reading the old HTML guidance on processing unknown
items in a HTML document. These are well-supported and have allowed much
useful work to be done, even with the worst invalidities. Perhaps
they've also encouraged such practices..... Unknown attributes should
be ingnored silently. Unknown elements should be ignored, but their
contents rendered (as if the element wasn't there)
http://www.w3.org/TR/REC-html40/appendix/notes.html#h-B.1
So use bizarre attributes without too much worry, but be careful of
elements with content, lest that content suddenly appear in your HTML
page where you weren't expecting it.
xml:lang="en" is described in the XML spec.
http://www.w3.org/TR/2004/REC-xml-20040204/#sec-lang-tag
and mentioned in the XHTML spec here
http://www.w3.org/TR/xhtml1/#C_7
Note that although this is a standard XML feature, it's not an implicit
feature. You still need to define the attribute in the application's
DTD, hence the XHTML DTD contains the following snippet.
<!-- internationalization attributes
lang language code (backwards compatible)
xml:lang language code (as per XML 1.0 spec)
dir direction for weak/neutral text
-->
<!ENTITY % i18n
"lang %LanguageCode; #IMPLIED
xml:lang %LanguageCode; #IMPLIED
dir (ltr|rtl) #IMPLIED"
>
This attribute is in turn part of the %attrs; entity, and so is allowed
on most XHTML elements (any of them, except for elements used in <head>)
[Back to original message]
|