Wednesday, October 8, 2008

Font Size - Relative Size Keywords

There are two font-size relative size keywords - smaller and larger which decrease or increase the font size of text with respect to the inherited size.
Example 1: <p>Some text here <span style="font-size: larger">span text</span></p>
Example 2: <p style="font-size:small">Some text here <span style="font-size:larger">larger span text</span></p>
Example 3: <p style="font-size:15px">Some text here <span style="font-size:smaller">smaller span text</span></p>
There are 5 ways to use relative size keywords on an element:
  • On their own - the ancestors of the element do not have their text sized using the font-size property
  • With absolute size keywords - the ancestors of the element have their text sized using the absolute sized keywords
  • With absolute length units - the ancestors of the element have their text sized in in, cm, mm, pt or pc
  • With relative length units - the ancestors of the element have their text sized in em, ex or px .
  • With percentages - the ancestors of the element have their text sized in percentages.

No comments: