Besides the ability to resize in IE6 (which is still, alas, a very popular browser), relative fonts give you a greater likelihood of matching the needs of users by default without changing them (or knowing how to do this if we talk about inexperienced users here). The user - or someone on their behalf - may have an increased font size as a DPI, OS, or browser setting for valid reasons (for example, blurred vision) and with a relative size, you can use this information to your advantage.
Use 'px for text that should fit with other elements on the page that are in pixels (i.e., images). For others, '%. The question suggests that using relative font sizes is somewhat difficult; I do not think so.
Usually you set one font size to '% on the body, and some on other page elements that are more or less important than the general body text. You rarely need to have enough nesting levels and nested fonts that you cannot easily track.
There is nothing about sizes relative to their parent size, which is especially difficult to understand, and this property can be useful: if you want to change the main font size on your page or part of it, you can just change it once, and you don’t have to fix each size declaration font on the contained elements.
The only real difficulty with relative is when you measure the size of a block relatively, but want to change something inside it back to its original size. You can work out a percentage that is inverse to the parent percent, but it is likely to be an ugly number, and you can get 1px rounding errors if you cannot / cannot specify it fully. In this random case, it might be a good idea to step back and look at the selector, see if you can apply the selection more selectively to avoid undoing it.
It would be, admittedly, nice if we had a unit that applied only to the user's default size, and not to the parent sizes, to attack such problems. Unfortunately, the only values ​​that work are the smallest / smallest / small / medium / etc. keywords that are pretty crude in addition to historical browser consistency issues.
bobince Nov 16 '08 at 1:35 2008-11-16 01:35
source share