Skip to content Skip to sidebar Skip to footer

Should I Use Html5 Syntax?

I was looking for a reference to make sure I was disabling an element correctly. When XHTML came out, I was always taught to disable an element like so:

Solution 1:

was all about making the HTML syntax more strict by following more rules.

Fewer rules actually. They removed exceptions. For example "Attribute values must be quoted unless the value conforms to certain conditions" became "Attribute values must be quoted".

Of course, you then add in the HTML compatibility guidelines, because XHTML never really took off and almost everyone served it as text/html resulting in "Elements that cannot have content must have the end tag omitted" becoming "Elements that cannot have content must have the end tag omitted and use self-closing tag syntax instead".

I mean, it looks like the upcoming HTML5 syntax will be much more loose, like the old school days before XHTML.

The syntax rules basically encompass everything that was allowed in HTML and XHTML with differences between the two falling on the XHTML side. (e.g. <foo /> means <foo> and not <foo>&gt;).

Should I use the HTML5 syntax style (the one in the W3C working draft)

The question as to the style you use is somewhat subjective. There are merits to both the conciseness of leaving out things that are optional and the explicitness of not.

If you use HTML5 then you should write valid HTML5. The example you give is not the only acceptable approach though.

Solution 2:

If you're using the HTML5 doctype, what makes you think that you should not be using HTML5 syntax? HTML5 is not an XML variant - it's HTML.

That said, personally I always quote attribute values because it seems uncouth not to do so.

Solution 3:

This blog post on W3C should make things clear: HTML 5, one vocabulary, two serializations.

In short, HTML5 allows you to use either the HTML syntax or the XML syntax -- both are equally valid, so the choice is yours.

Personally, I would go with the HTML syntax because it's simpler, and further, HTML is not based on XML, so I don't see any reason to use the XML syntax.

Post a Comment for "Should I Use Html5 Syntax?"