Friday, October 17, 2008

Font Size - Relative Length Units - px

Pixels (px) are considered relative length units because the CSS specification defines a pixel as 1/96th of an inch on the display screen. Since the number of dots per inch on screens varies, the actual size of the CSS pixel would have to vary to conform to the specification. Thus, the size of a pixel, in CSS, is relative to the dots per inch of the display device. All major browsers do not conform to this CSS specification when rendering a web page on the screen - they consider one CSS pixel to be equal to one actual pixel on the screen. However, many browsers do render pixels relatively when printing web pages.
The font size of an element can be specified in pixels in the following way:
No minimum or maximum value is specified for font size pixel values. However, negative values are not permitted. Opera 9.5 does not render text in sizes less than 9px when the font size is declared in pixels.
Floating point numbers are allowed (example: p{font-size:16.5px}).However, the major web browsers differ in their handling of floating point px values.
Firefox 3 and Safari 3.1 round off the font size in this manner: After the decimal point, any number greater than 4 (that is, numbers 5 to 9) is rounded off to 1px (example: 19.5px is rendered as 20px text). However, it is the floating point size that is inherited by descendant elements.
Internet Explorer 6, Internet Explorer 7, and Opera 9.6 ignore the decimal portion of the font size property's value. In these browsers, a font size value of 15.6px , for example, is considered as just 15px .
Note: Internet Explorer 6 and Safari 3.1 do not allow the user to increase the size of text that is sized with pixels. Firefox 3, Opera 9.6 and Internet Explorer 7, however, allow this with the "zoom" feature. This zoom feature also increases the size of everything else on the web page.

Advantages and Disadvantages of Using Font Size Pixel Units

Sizing text using pixel values can be done with consistent results if non-integral values and sizes below 9px are avoided. However, text sizing with pixel values also makes web pages less accessible because Internet Explorer and Safari 3.1 don't allow users to resize the text.

No comments: