In HTML we use id's and classes. we can choose any name for id.Can we choose any name for class also? Or is there any specification name for classes ?
-
2Possible duplicate of [Difference between id and class in CSS and when to use it](http://stackoverflow.com/questions/12889362/difference-between-id-and-class-in-css-and-when-to-use-it) – Mike Mar 09 '16 at 04:59
1 Answers
From the HTML 5 specification:
The id attribute specifies its element's unique identifier (ID). The value must be unique amongst all the IDs in the element's home subtree and must contain at least one character. The value must not contain any space characters.
There are no other restrictions on what form an ID can take; in particular, IDs can consist of just digits, start with a digit, start with an underscore, consist of just punctuation, etc.
The attribute, if specified, must have a value that is a set of space-separated tokens representing the various classes that the element belongs to. The classes that an HTML element has assigned to it consists of all the classes returned when the value of the class attribute is split on spaces. (Duplicates are ignored.)
Also, there are style guides that define good and very used pattern for choose the values to use for id or classes, etc. I recommend you this one from W3Schools.

- 541
- 2
- 12