What do people mean when they say that there is no parent selector in css?

For example, let's say I have HTML similar to the one below. I do not select the parent which is ul?

ul
  margin: 50px

ul.test
  li hello
  li how are u
+4
source share
1 answer

To understand what they mean, you need to understand what to choose means CSS( parent ):

, CSS. , CSS, ( ), - . . (, , ).
( , , , , ).

:

ul { 
  /* rules apply to all ul */
}

, :

ul > * { 
    /* rules apply to * (all children of ul) */
}

:

* < ul { 
  /* rules don't apply. this is invalid */ 
}

, , ...

* > ul {
  /* rules apply to any ul that is a child of * (any element) */
}

, .

CSS. . . it?


, .

, , 10 (, / , ):

<div>
  <whatever></whatever>
</div>
<span>
  <whatever></whatever>
</span>
<ul>
   <li>
     <whatever></whatever>
   </li>
   <li></li>
   <li>
     <whatever></whatever>
   </li>
 </ul>

CSS, ( ) <whatever> , , DOM. ?
: .

, , , :has(), . CSS, , . , //. CSS .

:has() ( <).

: @Maximus , shadow DOM DOM :host. , DOM DOM, ( DOM), DOM .

+7

Source: https://habr.com/ru/post/1670152/


All Articles