Skip to Main Content or Page Contents
html CSS Units of Length Introduction
Used to be the most popular unit of measurement for the web. And usually taught to beginners learning CSS. With the advent of both mobile phones & also very large screens has resulted in a responsive revolution. A responsive site allows the design to respond to the users screen size. Responsive design requires some usage of Relative Units
Pixels (1px = 1/96th of 1in)
Pixels (px) are relative to the viewing device. For low-dpi devices, 1px is one pixel (dot) of the display. For printers and high resolution screens 1px may be multiple pixels on that device.
centimetres. Mainly used for print.
millimetres. Mainly used for print.
inches (1in = 96px = 2.54cm). Mainly used for print.
points (1pt = 1/72 of 1in). Mainly used for print.
picas (1pc = 12 pt = 1/6in). Mainly used for print.
Cons em sizes cascade, which may result in unexpected sizes
1 rem is the computed value of the pixel font-size property for the parent elements usually the <html> element.
Example:
@media only screen and (max-width: 700px
{
html { font-size: 14px; }
@media only screen and (max-width: 640px)
{
html { font-size: 12px; }
}
REM will not work in old browsers IE 8, Safari 4, or IOS 3.2.
Percentages units allow the sizing of elements relative to their containing block.
If the text size of body is 16 pixels, then 150% of 16 will be 24 pixels (150% * 16).
Relative to 1% of the width of the viewport
vh: 1% of viewport height
Relative to 1% of viewport's smaller dimension
Internet Explorer 9 supports vmin with the nonstandard name: vm.
Relative to 1% of viewport's* larger dimension
Internet Explorer 9 Not supported
Based on the height of the letter x. Dramatically changes with different fonts. Very rarely used
ch stands for character. Relative to width of the "0" (zero) glyph. Very rarely used. Ideal for sizing monotype fonts
This site is hosted on Hostgator