1

I have simple p tag having heading I have set the font-size to paragraph tag however when I set the font-size to heading tag in terms of em unit, the changes are not getting reflected for em

p {
  font-size: 32px;
}

h2 {
  font-size: 2em;
}
<p>Heading<h2>SubHeading</h2></p>

However when I change paragraph to div em font size works correctly. like below

div {
  font-size: 32px;
}

h2 {
  font-size: 2em;
}
<div>Heading<h2>SubHeading</h2></div>

Why it is behaving like this ?

user1441238
  • 165
  • 1
  • 2
  • 10
  • 6
    Because `h2` are not valid children of `p` tags. Inspect your snippet output. The `h2` is being put outside of the `p` – Taplar May 22 '20 at 18:09

0 Answers0