Attributes not in key="value" format

Since when was this OK:
[COLOR=#110000]
<input type=“checkbox” checked>

in particular the checked being like that rather than in key=“value” format?

I’ve never come across that until just recently in starting to learn HTML5 in detail. I’ve always used XHTML in the past. Is that why [/COLOR][COLOR=#110000]<input type=“checkbox” checked> is so alien to me? Was that kind of thing OK in all previous versions of HTML (not XHTML)? I suspect that’s the case.

Thanks.[/COLOR]

It is valid in HTML 4.01, and obviously not in XHTML since Attributes may not be minimized in XML. http://www.w3.org/TR/xhtml1/diffs.html#h-4.5. In HTML 4.01, boolean attributes may appear in minimized form - the attribute’s value appears alone in the element’s start tag.

ckecked="checked" … To quote Jeremy Keith, “This is brought to you by the Department of Redundancy Department”. I’m glad that HTML5 has stuck with simple Boolean attributes, like checked, autoplay, controls etc. Much neater.

It is of course still okay to use the name-value pairs version in HTML5. The spec allows the shortened version in the cowpaths-paving sense: browsers generally accepted them and honestly don’t care; developers care.

I notice I tend to keep with the key-value pairs for consistency: elements having a mixture of types at least look like they were written by one person :stuck_out_tongue:

In XHTML5 you must use checked=“checked” - all versions of XHTML require the long version or you end up with an error in your page and the rest of the page gets chopped off.

Yes, by HTML5 I did mean the non-XML variant.

Right, thanks for confirming that.

<input checked> is equivalent to <input checked=“”> i.e. the value is the empty string. The latter syntax is allowed in both HTML and XHTML.

Also, any attribute may use the minimized form (assuming the empty string is a valid value) in HTML these days, not just boolean attributes.