Units
Distance and size units can be specified as absolute values that will be consistent regardless of their context:
Width: 50px; margin-left: 2em;
You can use any of the following absolute units. Note that there is no space between the value and the unit:
- • cm (centimeter; 1cm = 10mm)
- • in (inch; 1in = 2.54cm)
- • mm (millimeter)
- • pc (pica; 1pc = 12pt)
- • pt (point; 1pt= 1/72 in)
These units can be specified as percentages to define sizes in relative terms that are calculated with respect to their context (the size of the browser window, the size of the table, and so on):
width: 80%;
You can use any of the following relative units. Note, again, that there's no space between the value and the unit:
- • em (em, the height of the element's font)
- • ex (x-height, the height of the letter x)
- • px (pixel, relative to the screen resolution; 72 dpi is an average EGA/VGA screen resolution, giving 72 pixels to the inch)
Color units are used by various properties to define colors. You can specify the colors using the same hexadecimal code system as HTML uses. This consists of a hash symbol (#) followed by a pair of hexadecimal characters (00 to FF) for red (#FF0000), green (#00FF00), and blue (#0000FF), where 00 is nothing and FF is the maximum of that color. You also can specify percentages of red, green, and blue, although the simplest way is to name the color you want:
color: #FF0000; color: rgb(100%,0%,0%);