0
id vs class what different?
5 ответов
+ 3
An id has to be unique.
An element may have several classes, and several elements may belong to the same class.
+ 1
There Can Many Differences In It Like :
id Are Unique and Applied To Any Specific Element But Class Can Be Applied Any No Of Element.
In CSS id Styling Starts With Pound Sign (#) But Class Styling Starts With Dot(.) Sign.
0
id is unique
class can be use by a lot element
0
plus when referring to id you us # sign but for class you us . (dot)
0
Id attribute is used as a hook in html file for individual styling of elements . Although Id attribute can be used in as many elements as required but no two elemen's Id can have the same value . In css #idName is the selector syntax to style a particular element using its I'd name.
Class attribute is just like Id but unlike Id , multiple elements can have the same class value, and it is generally used to style a group of elements.I n css .className is the correct selector syntax to style a group of elements having the same class value.