Can I override the fixed font size of a parent element (e.g. div) with a non-fixed font size.
I have a problem where for a particular HTML page, I would like the element to use a font size relative to the Body element and not relative to the parent div.
My HTML
<body id="templateBody">
<div>
<p>
My CSS
body{
font-size: 76%
}
div{
font-size:11px
}
How do I specify a font size for p so that it is relative (%age) of the Body font size and not the fixed div font size? Is there anyway to override the div’s fixed font size without changing the div’s style? I tried using rem, but it does not work on IE8…
You cannot. Once you have set the parent element’s font size, there is no way of referring the font size of the parent’s parent.
The
remunit, in addition to browser support issues, refers to the font size of the root element, which is always thehtmlelement in HTML documents. So if the thebodyfont size is set as a percentage, you could indirectly set thepfont size as relative to it, but only in the sense of setting it as relative to the root element’s font size.There is normally little sense in mixing px and % font sizes in a document.