A look at the new CSS3 units of measure


So if you have been developing for any length of time then you are probably familiar with ‘em’, ‘%’and ‘px’ as units of measurements in CSS. As part of the CSS3 specification there are a few new  units of measurement that I think are worth casting an eye over.

  • ex’ This represents the height of a lowercase character in the elements font, it’s sometimes referred to as the x-height because in many cases it is equal to the height of the lower case x, it resents about half size of a font’s height. The usefulness of this measurement is questioned in this blog post.
  • ch’ width of the "0" glyph in the element's font. At first this might not appear to be that useful, but in monospace fonts it can be used to accurately measure text. Here is a real world use for this measurement.
  • rem’ font size of the root element. In practical terms the root element is the HTML element. This way you can set a font size on the HTML element and then use a rem to size a font relative to that element anywhere in the document. There is a nice blog post here detailing it’s real world use.
  • vw’ viewport's width – You can resize elements based upon the width of the viewport (the rectangular viewing region of the browser) that is currently viewing the website.  It’s use is discussed here.
  • vh’ viewport's height  - You can resize elements based upon the height of the viewport that is currently viewing the website. It’s use is discussed here.
  • vm’ minimum of the viewport's height and width – This tells you what is smaller out of either vw or vh. In the specification there is currently an issue which asks if this is still required. Since a developer could simply use the new min function instead. e.g min(1vh, 1vw);
Comments (1)

  1. bonave2008 says:

    It is a unit of measurement equal to the current font size. The height of the em unit can be different in different parts of the document. When users can change the size of text in their browser, the em unit can vary in relation to the size of the text that the user has selected.

    ex:

    p {

    font-size: 0.8em;

    }

    http://www.corelangs.com/…/units.html

    Bona

Skip to main content