Saturday, May 18, 2024
HomeJavaScriptThe :the place pseudo selector in CSS – Js Craft

The :the place pseudo selector in CSS – Js Craft


The CSS :the place is similar to the :is pseudo selector. Which means if we write:

p :the place(.major, .spotlight) {
    background-color: yellow;
}

It’s going to function a much less verbose means of writing:

p .major, 
p .spotlight {
    background-color: yellow;
}

Nevertheless, the distinction between :is and :the place is given by the specificity of those selectors.

Whereas :is has the specificity equal to the selector parameter with the best specificity, the :the place has zero specificity.

Let’s check out the under code:

kind p, kind #major { coloration: pink }
kind :is(p, #major) {coloration: pink}
kind :the place(p, #major) {coloration: pink}

From a concentrating on viewpoint, all three strains do the identical factor. They set a pink coloration to any p ingredient or any ingredient with an id of major that’s set inside a kind.

Hover the distinction is given by the specificity energy of those guidelines:

  1. the primary two guidelines kind p and kind #major have a specificity of 0,0,2 (two parts) and 1,0,1 (one id and one ingredient)
  2. the second rule kind :is(p, #major) comes with a specificity of 1,0,0 (the best handed selector is an id)
  3. and the third rule kind :the place(p, #major) has only a specificity of 0,0,1 (solely the shape ingredient is taken into consideration, as :the place(p, #major) has a zero specificity)

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments