0

i don't know how to select only the h1 without the span in css HTML:

  <h1>
    <span>hello from spam</span>
    <br> 
    heloo from h1 
  </h1>

2 Answers2

0

There are no parent selectors in CSS. Check:

Is there a CSS Parent selector?

Parent selectors in CSS

What you can do is styling both elements and then re-writing the style for the child. e.g.:

h1{
    color:blue;
}

h1 > span{
    color:black;
}
Chüngel
  • 350
  • 3
  • 19
-1

You can add style inside tag <h1> . For example:

<h1 style="color:red;">
Pete
  • 51,385
  • 23
  • 99
  • 140
Miosotaa
  • 27
  • 1
  • 11