Skip Navigation

TIL you can do #myId#myId#myId span { ... } and it makes a difference over #myId span { ... }

developer.mozilla.org Specificity - CSS: Cascading Style Sheets | MDN

Specificity is the algorithm used by browsers to determine the CSS declaration that is the most relevant to an element, which in turn, determines the property value to apply to the element. The specificity algorithm calculates the weight of a CSS selector to determine which rule from competing CSS d...

Specificity - CSS: Cascading Style Sheets | MDN

Adding the same id multiple times increases the specificity of a selector and thus overrides other selectors.

e.g.

#myId span {color: red; }
#myId#myId#myId span { color: blue; }

Codepen

0
0 comments