---
title: "CSS Units Reference - Length Unit Guide - AllTools"
description: "AllTools CSS Units Reference explains when to use px, rem, em, vw or vh and how they relate, helping you pick a scaling base for responsive layouts."
canonical_url: "https://tool.warmday.wang/en/info/css-units"
meta:
  author: AllTools
  keywords: "online tools, AllTools, free online tools, developer tools, image tools, PDF tools, text tools, unit converter, no login, browser-based tools"
  "og:description": "AllTools CSS Units Reference explains when to use px, rem, em, vw or vh and how they relate, helping you pick a scaling base for responsive layouts."
  "og:image": "https://tool.warmday.wang/img/og-cover.png"
  "og:image:alt": "AllTools Logo"
  "og:image:height": "630"
  "og:image:width": "1200"
  "og:title": "CSS Units Reference - Length Unit Guide"
  "twitter:image": "https://tool.warmday.wang/img/og-cover.png"
---

> Index of every page on this site: [llms.txt](https://tool.warmday.wang/llms.txt)

# **CSS Units Reference**

CSS length units reference with real-time conversion, visual comparison.

### **Absolute Units**

| **Unit** | **Name** | **Description** | **Conversion** |
| --- | --- | --- | --- |
| **px** | pixels | Base unit for screen display | 1px = 1px |
| **pt** | point | Print unit, 1pt = 1/72in | 1pt = 1.333px |
| **pc** | pica | Print Unit, 1pc = 12pt | 1pc = 16px |
| **in** | in | 1in = 96px = 2.54 cm | 1in = 96px |
| **cm** | Centimeter (cm) | Metric Length Units | 1cm = 37.795px |
| **mm** | Millimeter (mm) | 1mm = 0.1cm | 1mm = 3.7795px |
| **Q** | Quarter millimeter | 1Q = 0.25 mm | 1Q = 0.9449px |

### **Relative Units**

`**em**`**Relative font size**

font-size relative to the current element

font-size: 16px → 1em = 16px

`**rem**`**Root Element Font Size**

font-size relative to root element (html)

html {font-size: 16px} → 1rem = 16px

`**vw**`**Viewport Width**

1% of viewport width

Viewport width 1920px → 1vw = 19.2px

`**vh**`**Viewport Height**

1% of viewport height

Viewport height 1080px → 1vh = 10.8px

`**vmin**`**smaller of vw/vh**

the smaller of vw and vh

min (vw, vh)

`**vmax**`**larger of vw/vh**

the larger of vw and vh

max (vw, vh)

`**%**`**Percentage**

Corresponding properties relative to the parent element

Parent element width 400px → 50% = 200px

`**ch**`**CharacterWidth**

Width of number 0

1ch ≈ 1 character wide in monospace fonts

`**ex**`**x-height**

Height of lowercase letter x

Approximately 0.5x em

`**lh**`**Row Height**

The line-height value of the current element

line-height: 24px → 1lh = 24px

`**rlh**`**Root Element Line Height**

line-height value of the root element

Root line-height: 24px → 1rlh = 24px

`**cap**`**Uppercasecap height**

Uppercase Height

Font Related

`**ic**`**Ideograph Width**

CJK Character Width

1ic ≈ 1 Chinese character width

### **Common Design Specs**

**Root Font Size Default**

Browser default font-size

`1rem = 16px`

**Commonroot font sizeSettings**

easier calculation

`62.5% → 1rem = 10px`

**Print Resolution**

Fixed conversions in CSS

`1in = 96px (CSS)`

**mobile breakpoint**

sm/md/lg

`640px / 768px / 1024px`

**Safe Area**

iOS notch adaptation

`env(safe-area-inset-*)`

**1dp/pt (mobile)**

Device Pixel Ratio Correlation

`≈ 1.5-3px`

### **Usage**

#### **Unit Categories**

Absolute Unit

#### **Converter Usage**

Enter a value in the Unit Conversion tab and select the source unit, and the list shows the equivalent results of that value in other absolute units in real time. All conversions are based on px as the intermediate benchmark: source value x source unit baseRatio = pixel value, divided by the target unit baseRatio

#### **Suggestions for use**

Responsive layout prefers to use rem and vw/vh; font size setting recommends rem for uniform scaling; spacing can be em or rem; precise pixel control scenes use px; print style sheets use physical units such as pt, cm, mm. Setting the root font size to 62.5% allows 1rem = 10px for easy mental calculation

#### **Notes**

The default root font size of the browser is 16px, which can be adjusted by the user in the system settings, so the actual pixel value of the rem unit will fluctuate according to the user's preference; vw/vh contains the width of the scroll bar (some browsers), if you want to exclude the scroll bar, you can use svw/svh (small viewport) or lvw/lvh (large viewport); ch units represent only the width of the number 0 in non-equal-width fonts, not the same as the width of ordinary characters.

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://tool.warmday.wang/#organization","name":"AllTools","alternateName":"AllTools - 全能工具箱","url":"https://tool.warmday.wang/","logo":{"@type":"ImageObject","url":"https://tool.warmday.wang/img/logo.png","width":512,"height":512}},{"@type":"WebSite","@id":"https://tool.warmday.wang/en#website","url":"https://tool.warmday.wang/en","name":"AllTools","inLanguage":"en","publisher":{"@id":"https://tool.warmday.wang/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://tool.warmday.wang/en?q={search_term_string}"},"query-input":"required name=search_term_string"}},{"@type":"WebPage","@id":"https://tool.warmday.wang/en/info/css-units#webpage","url":"https://tool.warmday.wang/en/info/css-units","isPartOf":{"@id":"https://tool.warmday.wang/en#website"},"inLanguage":"en","name":"CSS Units Reference - Length Unit Guide","description":"AllTools CSS Units Reference explains when to use px, rem, em, vw or vh and how they relate, helping you pick a scaling base for responsive layouts."},{"@type":"BreadcrumbList","@id":"https://tool.warmday.wang/en/info/css-units#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://tool.warmday.wang/en"},{"@type":"ListItem","position":2,"name":"Reference","item":"https://tool.warmday.wang/en/info"},{"@type":"ListItem","position":3,"name":"CSS Units Reference","item":"https://tool.warmday.wang/en/info/css-units"}]}]}
```

## Sitemap

See the full [sitemap](https://tool.warmday.wang/sitemap.md) for all pages.
