Trying the "Eric Meyer Reset" I stumbled across an issue concerning the font-size:100%
declaration to reset the font size of all suitable elements. font-size:100%
means the elements should inherit font-size
property of their parent, but this is not the case with the <sub>
and <sup>
elements and their descendants in IE (tested in 6,7,8 and 9th version).
For example (or this live example on a playground):
// CSS:
sup,span {font-size:100%;}
// HTML:
if you try this in IE, <sup>this text will be smaller <span>and this even more</span></sup>
It seems like just another implementation trick, that IE plays on webdesigners, since this is not the only glitch of these elements. My guess is that IE applies some own hard-wired styling on the <sub>
and <sup>
elements which makes their content smaller in addition to being sub-/superscripted, but I can't find a way to reset this behaviour, if any exists at all.
// Please respond directly to this issue, suggestions like "use an UA specific stylesheet" may satisfy your feeling of being helpful, but doesn't satisfy the topic :-) ..EDIT: Ok, this plea has finally turned against me, but I wanted to state at least one answer to this topic here.
EDIT: It looks like IE (all versions till IE9) multiplies the font size of the <sub>
and <sup>
and their descendants with some variable coefficient (sth between 0.6 – 0.8 depending on the font-size).
The reasoning is following: when a fixed size (e.g. font-size:15px
) is set on the <sup>
tag and all its descendants, they all have the font size around 10px (≅ 0.7 × 15px). But, when a relative size is being set instead (e.g. font-size:100%
), the coefficient effect is propagated from the <sup>
element down to its descendants – so 1st-level descendant has the font size around 70% (≅ 0.7 × 100% of its <sup>
parent), 2nd-level descendant has the font size around 50% (≅ 0.7 × 0.7 × 100% of its <sup>
ancestor) and so on. This propagation breaks when font-size:inherit
is used, since it means the element should have exactly the same size as its parent – this works for the descendants of the <sup>
element, but the <sup>
element itself is still given a smaller font size by IE than its parent element does have.
The coefficient theory :-) taking part in IE can be seen on this example. Also compare this with any of the "standard compliant" browsers.
For most font-relative units (such as em and ex ), the font size is relative to the parent element's font size. For font-relative units that are root-based (such as rem ), the font size is relative to the size of the font used by the <html> (root) element.
When you set font-size on an element, the element certainly does not inherit font size. This is about the effect of the relative nature of the em unit.
The font-size property in CSS is used to specify the height and size of the font. It affects the size of the text of an element. Its default value is medium and can be applied to every element. The values of this property include xx-small, small, x-small, etc.
It is related to the font size of the parent container. One em (1em) is equal to the current font size. So for example, if the parent element has the font size of 16px than 1em is equal to 16px, 2em is equal to 32px, and so on. Making your design responsive becomes much easier if you use em units instead of px.
It seems like the only "solution" to leave the font-size:100%
reset-declaration in the stylesheet and still have acceptable sub-/superscripts is so far either to:
<span>
. Definitely not a good idea in the light of semantics → eliminated.font-size:inherit
to have at least the descendants of <sub>
or <sup>
be the same size by default in IE ≥ 8 → accepted.solution #2, this will do the trick (sure it can be tuned up, but just the concept):
<!--[if IE]>
<style>
sup *,sub * {font-size:120%; font-size:inherit;}
</style>
<![endif]-->
provided you don't strive for maximum performance (See the *
selector performance issue).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With