This website may use cookies. More info. That's Fine x
Welcome Login

Units


Css

Length units

A length value is formed by an optional + or -, followed by a number, followed by a two-letter abbreviation that indicates the unit.

There are no spaces in a length value

Eg:

1.3 em is not a valid length value, but 1.3em is valid.

 

A length of 0 does not require the two-letter unit identifier.

Both relative and absolute length units are supported in CSS1.

Relative units give a length relative to another length property, and are preferred since they will better adjust to different media.

Relative units available:

px : pixels, relative to the canvas resolution, is a dot on the computer screen

em : ems, the height of the element's font 
     Note: 1em is equal to the current font size. 
           2em means 2 times the size of the current font. 
           Eg: if an element is displayed with a font of 12 pt, then '2em' is 24 pt. 
          
     The 'em' is a very useful unit in CSS, since it can adapt automatically to the font that the reader uses.
         
ex : x-height, the height of the letter "x"

 

 

Absolute length units are highly dependent on the output medium, and so are less useful than relative units.

Absolute units available:

in : inches; 1in=2.54cm

cm : centimeters; 1cm=10mm

mm : millimeters

pt : points; 1pt=1/72in

pc : picas; 1pc=12pt

 

 

 

Percentage units:

A percentage value is formed by an optional + or -, followed by a number, followed by %. There are no spaces in a percentage value.

Percentage values are relative to other values, as defined for each property.

Most often the percentage value is relative to the element's font size.


Created on: Wednesday, March 2, 2011 by Andrew Sin