Absolute Length Units

Term side of the Card.
Topic: Measurement Units
Unit title: Absolute Length Units
Categories: Concept
Explanation side of the Card

Explanation: The units, such as 'px', 'cm', 'mm', 'in', 'pt' and 'pc', that represent fixed sizes. They don't change based on screen size or resolution, making them useful when precise control over layout is needed.

Browser compatibility:
  • The chrome browser supports this feature starting from version 1.
  • The edge browser supports this feature starting from version 12.
  • The firefox browser supports this feature starting from version 1.
  • The safari browser supports this feature starting from version 1.
Availability: 

Example

Wrongcss
html {
  font-size: 16px;
}
Rightcss
html {
  font-size: 100%;
}

'100%' keeps the user's default font size, while '16px' ignores the browser text size setting.

Common mistakes

  • Expecting '1cm' to measure one real centimeter on a screen.
  • Setting html { font-size: 16px }, which overrides the user's chosen text size.

Key points

  • Root and body font sizes use rem or '%', not 'px', so text follows the user's default font size.
  • Physical units like 'cm', 'mm' and 'pt' appear only in print styles, not in screen layouts.
  • Borders, shadows and hairlines use 'px', where a fixed size is intended.

Interview questions

How many pixels is 1in in CSS?

Exactly '96px'. CSS fixes '1in' to '96px', so '1cm' is about '37.8px' and '1pt' is '1/72in'.

Is px an absolute unit in CSS?

Yes. A CSS pixel is a fixed reference unit, but on high-density screens one CSS pixel covers several device pixels.

When should I use pt in CSS?

Use 'pt' mostly in print style sheets, where font sizes in points match what printed documents expect.

Analytics cookiesWe'd like to use analytics cookies to see which pages are useful. They're set only if you accept. Privacy Policy