HTML5: Valid characters for the ID attributeHTML5: Valid characters for the ID attribute

Posted August 2nd, 2010 in HTML and CSS

A while back I posted the rules around the use of the HTML ID attribute; the post was specific for HTML4 and I obviously need to post an update to allow for HTML5 which is a lot more flexible.

HTML5 id attribute

It's pretty simple really, the HTML5 id attribute can contain any character other than a space, and it can also start with any character. Obviously there may be some backward compatible issues if you do start using any old character in your id attributes, but the older browsers are generally fairly relaxed at allowing most characters anyway.

For more information and a bunch of examples, read the post "The id attribute just got more classy in HTML5" on Mathias Bynens' blog. There's some useful comments on that page as well.

Related posts:

Comments

blog comments powered by Disqus