Html 5 Classnames And Ids
Solution 1:
I’ve researched this thoroughly and wrote about my findings: The id
attribute got more class
y in HTML5. From that article:
HTML5 gets rid of the additional restrictions on the
id
attribute. The only requirements left — apart from being unique in the document — are that the value must contain at least one character (can’t be empty), and that it can’t contain any space characters.
To target a classname or ID that starts with a digit in CSS or in JavaScript using the Selectors API, you should escape them. For example, to target the element with id="404"
, you can’t just use #404
— you’d have to escape it as follows:
#\3404 {
background: pink;
}
Solution 2:
The official html5 specs are here: id-attribute in html5.
(Here you go for html4)
So in html5 the only restriction is minimum 1 char and no whitespaces.
Post a Comment for "Html 5 Classnames And Ids"