Reputation: 20049
When XHTML came around I moved to following all the necessary rules like everybody, closing empty tags:
<meta />
<br />
<img />
always using lowercase, always putting attribute values in quotes, avoiding attribute minimisation:
checked="checked"
...and so on.
Now, since the move to HTML5 as I understand it you can still utilise those same standards within HTML5, as there could be XHTML within HTML4 or XHTML within HTML5, basically meaning you could still utilise XHTML's rules within HTML5 - it's not one or the other.
Now, the reason I am talking about this is because I started wondering about the xmlns
attribute of the html
element that I have been using, that being: xmlns="http://www.w3.org/1999/xhtml"
.
Now as I understand it this became a requirement with the introduction of XHTML but I have continued using it within HTML5.
So my question is, if I wanted to keep using XHTML's standards within HTML5 do I have to continue inserting this attribute into my html
element?
...and if so, I would assume if I coded inavlid XHTML such as <br>
then it would become invalid just like it previously would?
Upvotes: 1
Views: 190
Reputation: 5484
Objectively
In HTML 5 it is not strictly required to close certain tags, use lowercase attributes and values, and avoid attribute minimisation. However, the markup will be valid whether you do or not.
Like all previous version, HTML 5 does not allow end-element tags for img
, br
and other self-closing elements, but will merely tolerate those as part of error recovery that is part of the specification.
HTML 5 does not require a reference to a DTD (Document Type Definition). This is because HTML 5 is no longer based on SGML. Browsers cannot parse HTML 5 as SGML for compatibility reasons.
Furthermore, HTML 5 - like HTML 4 - can not contain an xmlns (XML namespace) attribute, because it's markup does not describe XML.
There is also an answer about the XHTML5 specification. In short, XHTML was abandoned for HTML5 and now only refers to a syntax. Additionally you can still use HTML5 in XML serialization mode. For this the document must be served as application/xhtml+xml
.
Subjectively
You do not have to throw away the practices you have learned, writing valid XHTML. There is no point to avoiding attribute minimisation anymore, but closing empty tags and always using lowercase could make a great difference in code readability, depending on the preferences of your team.
Upvotes: 1