Class IDs and Attributes in HTML5
I believe what you are talking about in this article . Well, nothing has changed - class
es and id
are used the same as in HTML4.
Except for one thing: the HTML4 spec says the following
ID and NAME must start with a letter ([A-Za-z]) and can be followed by any number of letters, numbers ([0-9]), hyphen ("-"), underscore ("_"), colons (":") and periods (".").
However, in the HTML5 spec, the requirement for a id
much less stringent
The value must be unique among all identifiers in the elements of the subtree and must contain at least one character. The value must not contain any whitespace characters.
This way HTML5 id
can accept more characters, which means the article you are talking about .
source to share
Attributes still have two different purposes:
-
class
can contain multiple classes, and multiple elements can have the same classes -
id
contains one identifier, and this identifier can only be used for item one .
The assertion you indicated exists because some restrictions on how IDs should look like were removed in HTML5 - classes never had these restrictions.
source to share
The difference between ID
and class
is that it ID
must be unique on the same page, but class
can be used to multiply multiple times.
Both are valid HTML 5, you can validate your page here: http://validator.w3.org/
source to share