This is a must-read within this particular context
Even though Percentages and Ems are considered to be the most effective method for font sizing, there are two key challenges that need to be addressed:
- Maintaining consistency across various browsers
- The impact of inheritance on nested elements
Ensuring Consistency Across Browsers
Different browsers interpret relative font sizing differently, particularly when it comes to inheritance. For instance, setting the font size in the body tag as follows:
body { font-size: 80%; }
Most browsers will display this as being 80% of the default font behavior of the element. A standard H1 tag typically renders at 200% default font size, so with the aforementioned rule applied to the page, an H1 heading would appear at 160% (200% x 80%= 160%) of the default font size.
Mac/Opera6 may not consistently implement this rule throughout the content. Text within tables could remain at the default size. On the other hand, Mac/Netscape4 and Win/Netscape4 might apply this rule to headings as well as text within paragraph tags - resulting in all content on the page being displayed at 80% size.
Inheritance and its Impact on Nested Elements
Relative font sizing also presents challenges related to inheritance and its effect on nested elements. For example, a rule like the one below could lead to inheritance issues:
p, ul { font-size: 85%; }
An example illustrating the problem with paragraphs and nested unordered lists.
Any content within a paragraph or unordered list will be scaled to 80% of the user's default browser size. The issue arises when there is a nested unordered list. The nested list item will inherit the relative font sizing and automatically apply it again, making the nested list items appear at 72.25% in size (85% x 85% = 72.25%).
This can be rectified by adding another rule that brings all nested list items back to 85% font size:
ul ul { font-size: 100%; }
For further information, click here