CSS-Lesson 4
CSS Units
Size
Size values can be split up into absolute and relative values. Some values (e.g. margins) can have negative values, preceded by '-'. Zero values do not require a unit.
Absolute values | ||
---|---|---|
Style abbreviation | Style meaning | Explanation |
in | inch | = 2.54 cm |
cm | centimetre | |
mm | millimetre | |
pt | point | = 1/72 inch |
pc | pica | = 1/6 inch (12 points) |
px | pixel | a dot on the screen |
Relative values | ||
---|---|---|
Style abbreviation | Style meaning | Explanation |
em | Height of capital 'M' | = 100% |
ex | Height of lowercase 'x' | |
% | percentage | 100% = 1em |
Color values
The values for colours can be specified in a number of different ways:
- as a 'name'. Various sources quote different numbers of colour names. The following seventeen fairly safe colours available are shown in CSS-Lesson 5.
- 'rgb(r,g,b)' where r, g, and b are decimal numbers between 0 and 255. This gives about seventeen million colours.
- 'rgb(r%,g%,b%)' where r, g and b are decimal numbers between 0 and 100. This gives 1,030,301 colours
- '#rgb' where r,g and b are hexadecimal numbers. This gives 4096 colours.
- '#rrggbb' where rr, gg and bb are two-digit hexadecimal numbers. This gives about seventeen million colours.
Notes

The property 'background-color' can also have the value 'transparent'.
To learn more about hexadecimal numbers click here.