johnyboy — 2013-03-29T09:08:53-04:00 — #1
Since when was this OK:
<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 <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.
xhtmlcoder — 2013-03-29T10:07:03-04:00 — #2
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.
ralphm — 2013-03-29T10:35:46-04:00 — #3
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
controls etc. Much neater.
stomme_poes — 2013-03-29T15:40:31-04:00 — #4
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
felgall — 2013-03-29T17:34:01-04:00 — #5
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.
stomme_poes — 2013-03-30T04:59:43-04:00 — #6
Yes, by HTML5 I did mean the non-XML variant.
johnyboy — 2013-03-31T12:08:25-04:00 — #7
Right, thanks for confirming that.
zcorpan — 2013-04-08T17:11:05-04:00 — #8
<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.