CSS:length
From MDC
[edit] Summary
Many CSS properties take length values, such as width, margin-top, and font-size.
The CSS syntax for lengths is a number followed immediately by a unit. Having a space between the number an the unit is forbidden.
For some properties, using negative lengths is a syntax error, but for some properties, negative lengths are allowed.
[edit] Units
- em
- The
font-sizeof the element. - ex
- The x-height of the element's
font. This is generally the height of lowercase letters in the font. - px
- For screen display, one pixel (dot) of the display. For very high resolution screens and for printers, multiple pixels, so that the number of
pxper inch stays around 96. - in
- One inch (which is 2.54 centimeters). For screen display, the number of pixels in an inch is determined by the system's estimate (often incorrect) of the resolution of its display.
- cm
- One centimeter (which is 10 millimeters). For screen display, the number of pixels in an centimeter is determined by the system's estimate (often incorrect) of the resolution of its display.
- mm
- One millimeter. For screen display, the number of pixels in an millimeter is determined by the system's estimate (often incorrect) of the resolution of its display.
- pt
- One point (which is 1/72 of an inch). For screen display, the number of pixels in an point is determined by the system's estimate (often incorrect) of the resolution of its display.
- pc
- One pica (which is 12 points). For screen display, the number of pixels in an pica is determined by the system's estimate (often incorrect) of the resolution of its display.
[edit] Examples
[edit] Notes
The syntax for percentages (number followed by % sign) is similar to the syntax for lengths. However, percentages are not a type of length, although some of the properties that take length values also take percentage values.