Which attribute is a higher priority in the CSS attribute ID or class?
- oneid Identifiers and classes | htmlbook.ru - greybutton
- @greybutton You should write a response by attaching a link to the original - Alex
|
1 answer
id - identifier, can be used to define one element (mainly used if js is applied to an element). The identifier is denoted by the name that follows the pound sign ( # ).
class - can be used to define multiple elements. In CSS, the class selector is denoted by the name that follows the dot ( . ).
By specificity (weight), the presence of id in the selector gives a higher priority than the presence of a class!
Those.
#my-id {color: red; } .my-class {color: green; } <div class='my-class' id="my-id">Применятся стили id</div> ps: if you about it!
- Thank you, yes about this - TomasRedl Nov.
|