-1

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
  • 14,640
  • 25
  • 121
  • 247

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>
cam
  • 3,179
  • 1
  • 12
  • 15