Ask HN: HTML/JS Standards Question
Good Code:
<div id="welcome">Hello</div>
Bad Code:
<DIV ID="welcome">Hello</DIV>
JavaScript:
document.getElementById("welcome").tagName;
For both, the code would return "DIV" and not "div".
Good Code:
<div id="welcome">Hello</div>
Bad Code:
<DIV ID="welcome">Hello</DIV>
JavaScript:
document.getElementById("welcome").tagName;
For both, the code would return "DIV" and not "div".
http://www.whatwg.org/specs/web-apps/current-work/multipage/...
"These attributes must return element names converted to ASCII uppercase, regardless of the case with which they were created."
It depends on the doctype and namespace. In XHTML, an uppercase HR is technically meaningless, since it is case sensitive. In HTML5, it is not case sensitive so hR should be valid, according to the spec.
Citation: "In the HTML syntax, tag names, even those for foreign elements, may be written with any mix of lower- and uppercase letters that, when converted to all-lowercase, matches the element's tag name; tag names are case-insensitive."
P.S. In HTML 4 and older, tags are case insensitive. And practical browsers will accept both cases for the foreseeable future.