I’m making a website and I’m using em for font size, but in body, font-size: 1.2em;
changes the size of my headers too. how can I stop this?
I tried
h1, h2, h3 {
font-size: inherit;
}
but that brings them to the size of the normal text.
I’m making a website and I’m using em for font size, but in body, font-size: 1.2em;
changes the size of my headers too. how can I stop this?
I tried
h1, h2, h3 {
font-size: inherit;
}
but that brings them to the size of the normal text.
2
Answers
To change only the size of normal text, not headers, with EM, you can use the following CSS:
This will set the font size of all paragraphs to 1.5 times the default font size. You can change the value of 1.5 to any size you want.
To make sure that the font size of the headers is not affected, you can use the following CSS:
Try using the
:not()
pseudo-class. Can I use:not()
? shows 93.74% browser support.