0

I am trying to apply color only parent level, by using :not() operator. but no result. is it possible?

html:

<header>title <span>123</span></header>

CSS:

header:not(header span){
  color: green;
}
<header>title <span>123</span></header>
header:not(header span){
  color: green;
}
3gwebtrain
  • 13,401
  • 21
  • 93
  • 195

1 Answers1

0

I would use two css rules, one specifically targeting the span to unset the color: green rule applied by the header css rule.

header {
  color: green;
}

header span {
  color: initial;
}
<header>title <span>123</span></header>
camaulay
  • 2,001
  • 6
  • 10