CSS Reference-Lesson 1

Each of the properties in CSS can have more than one value. In the following tables, the default value (indicated by '*') is the value of the property if the property is omitted.

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 '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:

  1. as a 'name'. Various sources quote different numbers of colour names. The following seventeen fairly safe colours available are:
    NamecolourHexadecimal equivalent
    aqua   #00ffff
    black   #000000
    blue   #0000ff
    fuchsia   #ff00ff
    gray   #808080
    green   #008000
    lime   #00ff00
    maroon   #800000
    navy   #000080
    olive   #808000
    orange   #ffa500
    purple   #800080
    red   #ff0000
    silver   #c0c0c0
    teal   #008080
    white   #ffffff
    yellow   #ffff00
  2. 'rgb(r,g,b)' where r, g, and b are decimal numbers between 0 and 255. This gives about seventeen million colours.
  3. 'rgb(r%,g%,b%)' where r, g and b are decimal numbers between 0 and 100. This gives 1,030,301 colours
  4. '#rgb' where r,g and b are hexadecimal numbers. This gives 4096 colours.
  5. '#rrggbb' where rr, gg and bb are two-digit hexadecimal numbers. This gives about seventeen million colours.

Notes

Note

The property 'background-color' can also have the value 'transparent'.

To learn more about hexadecimal numbers click here.

Previous Lesson previous lesson next lesson Next Lesson