CSS Unit Converter
Convert between CSS units — px, rem, em, vh, vw, pt, cm, mm, in, and more — instantly in your browser, nothing sent to any server
Input
⚙ Settings — Base font size: 16px · Viewport: 1440×900px▸
Conversion formula
value ÷ baseFontSize → 16 ÷ 16px = 1rem
All units
Quick reference table (px → rem / em / pt) ▸
| px | rem | em | pt |
|---|---|---|---|
| 1 | 0.0625 | 0.0625 | 0.75 |
| 2 | 0.125 | 0.125 | 1.5 |
| 4 | 0.25 | 0.25 | 3 |
| 8 | 0.5 | 0.5 | 6 |
| 12 | 0.75 | 0.75 | 9 |
| 14 | 0.875 | 0.875 | 10.5 |
| 16 | 1 | 1 | 12 |
| 18 | 1.125 | 1.125 | 13.5 |
| 20 | 1.25 | 1.25 | 15 |
| 24 | 1.5 | 1.5 | 18 |
| 32 | 2 | 2 | 24 |
| 48 | 3 | 3 | 36 |
| 64 | 4 | 4 | 48 |
| 96 | 6 | 6 | 72 |
| 128 | 8 | 8 | 96 |
What Is a CSS Unit Converter?
A CSS unit converter translates values between the many measurement units available in CSS — pixels, rems, ems, viewport units, physical units (cm, mm, in, pt), and more. Unlike a simple multiply-by-factor tool, this converter accounts for the context-dependent nature of CSS units: font-relative units depend on the base font size, viewport units depend on screen dimensions, and percentage units depend on the parent element’s size.
CSS Unit Categories
Absolute Units
Absolute units map to real-world physical measurements and are fixed regardless of screen settings.
| Unit | Full Name | Relation |
|---|---|---|
px | CSS pixel | 1/96th of an inch (CSS reference pixel) |
pt | Point | 1/72nd of an inch ≈ 1.333px |
pc | Pica | 12 points = 1/6th of an inch ≈ 16px |
cm | Centimetre | 1cm ≈ 37.795px |
mm | Millimetre | 1mm ≈ 3.7795px |
in | Inch | 1 inch = 96px |
When to use absolute units: px for screen design; pt and cm for print stylesheets. Avoid cm/mm/in for screen layouts — monitors don’t display at exactly 96 dpi.
Font-Relative Units
Font-relative units scale with the current font size, making them ideal for accessible, zoomable layouts.
| Unit | Full Name | Relative to |
|---|---|---|
rem | Root em | Root <html> element font size |
em | Em | Current element’s font size |
ch | Character width | Width of the 0 glyph in the current font |
ex | x-height | Height of the lowercase x in the current font |
rem vs em: rem is always relative to the root (predictable); em is relative to the nearest ancestor with an explicit font size (can compound through nesting). For layout and typography, prefer rem. Use em for component-level proportional sizing where elements should scale with their own font-size.
Viewport Units
Viewport units are relative to the browser window dimensions, enabling truly responsive full-screen layouts.
| Unit | Full Name | Relative to |
|---|---|---|
vh | Viewport height | 1% of the viewport height |
vw | Viewport width | 1% of the viewport width |
vmin | Viewport min | 1% of the smaller viewport dimension |
vmax | Viewport max | 1% of the larger viewport dimension |
Practical use: 100vh fills the full viewport height (ideal for full-screen sections). vw is useful for fluid typography and containers that should scale with the window width. vmin ensures elements stay visible on both portrait and landscape orientations.
Mobile caveat: On mobile browsers, 100vh includes the URL bar — use the new dvh (dynamic viewport height) unit in modern browsers to avoid this issue.
Percentage
% is relative to the parent element’s corresponding dimension. For width, 1% = 1% of the parent’s width. For font-size, 1% = 1% of the parent’s font-size.
How to Convert px to rem
The formula is straightforward:
rem = px ÷ baseFontSize
With the standard browser default of 16px:
| px | rem |
|---|---|
| 8px | 0.5rem |
| 12px | 0.75rem |
| 14px | 0.875rem |
| 16px | 1rem |
| 18px | 1.125rem |
| 20px | 1.25rem |
| 24px | 1.5rem |
| 32px | 2rem |
| 48px | 3rem |
Why use rem? When users change their browser’s default font size (an accessibility setting), rem-based layouts scale proportionally. px values are fixed and override this preference — a significant accessibility concern.
How to Convert px to em
em uses the same formula as rem when converting from px:
em = px ÷ currentFontSize
However, em refers to the current element’s font size, not the root font size. In a component with font-size: 20px, 1.5em = 30px — not 24px as with the root 16px baseline.
This is why em can compound in nested elements: if a parent has font-size: 1.2em and a child also has font-size: 1.2em, the child ends up at 1.2 × 1.2 = 1.44em relative to the root — a common cause of unexpected type scaling in CSS.
How to Convert px to Viewport Units
Viewport unit conversions depend on the viewport dimensions:
vw = (px ÷ viewportWidth) × 100
vh = (px ÷ viewportHeight) × 100
Example (1440×900 viewport):
288px=(288 ÷ 1440) × 100=20vw90px=(90 ÷ 900) × 100=10vh
Use the Settings panel in this tool to match your target viewport breakpoint (e.g., 1440×900 for desktop, 390×844 for iPhone 14).
When to Use Each CSS Unit
| Use case | Recommended unit | Why |
|---|---|---|
| Body font size | rem | Respects user’s browser font preference |
| Spacing (padding, margin, gap) | rem | Scales with root font size |
| Border widths | px | Fixed, predictable |
| Full-screen sections | vh / vw | Fills viewport |
| Fluid typography | vw with clamp() | Scales smoothly with viewport |
| Component-internal spacing | em | Proportional to component’s font size |
| Print stylesheets | pt, cm, mm | Maps to physical dimensions |
| Monospace code layout | ch | Column-aligned, font-aware |
| Container queries | cqi, cqb | (Not yet in this tool) |
The Pixel Is Not a Screen Pixel
A CSS px is a reference unit defined as 1/96th of an inch, independent of physical screen resolution. On a 2x Retina display, 1 CSS pixel is rendered using 2 physical pixels per side (4 physical pixels total). This is handled transparently by the browser — your CSS values always refer to CSS pixels.
This is why high-DPI displays look sharper: they have more physical pixels per CSS pixel, allowing the browser to render smoother edges, thinner lines, and crisper text without changing your layout.
Point (pt) vs Pixel (px): A Print Legacy
Points (pt) come from the print world where 72 points = 1 inch. In CSS at 96dpi:
1pt = 96/72px = 1.333...px
12pt ≈ 16px (common body text)
10pt ≈ 13.3px
Figma and Sketch display dimensions in points (matching iOS), so you may need to convert point values from design files to CSS pixels. This tool converts between pt and px exactly.
Responsive Design Workflow
A typical workflow converting a static design to responsive CSS:
- Get pixel values from your design tool (Figma, Sketch, XD)
- Convert to rem for font sizes and spacing (divide by your root font size)
- Convert to vw/vh for full-width/height containers
- Use px only for fixed elements (borders, box shadows, 1px lines)
- Use em for internal padding in buttons and components that should scale with their font
/* Static design: heading is 32px */
/* Root font: 16px */
h1 {
font-size: 2rem; /* 32 ÷ 16 = 2 */
margin-bottom: 1.5rem; /* 24 ÷ 16 = 1.5 */
}
/* Full-screen hero */
.hero {
height: 100vh;
width: 100%;
}
Frequently Asked Questions
What is the default browser font size?
All major browsers default to 16px for the root font size. Users can change this in browser settings (typically to 20px or 24px for accessibility). rem-based layouts will scale accordingly; px-based layouts will not.
Why does 1rem = 16px by default?
16px is the CSS specification default for the <html> element’s font size when no other styles are applied. It’s approximately the size that humans find comfortable for reading body text at typical monitor distances.
Can I use fractional px values?
Yes. CSS accepts sub-pixel values like 0.5px or 1.5px. Browsers handle sub-pixel rendering differently — some snap to the nearest physical pixel, others use anti-aliasing. For border widths, 1px is most reliable.
What are dvh, svh, lvh?
These are newer viewport units that address the mobile browser URL-bar problem. dvh = dynamic viewport height (changes as the URL bar shows/hides), svh = small viewport height (always the smaller size with URL bar visible), lvh = large viewport height (always the full size). This tool converts vh — for the newer units, multiply the vh result by the appropriate viewport dimension.
Does % always refer to the parent width?
Not always. % in width refers to the parent’s width. In height, it refers to the parent’s height. In margin and padding (all four sides), it always refers to the parent’s width — even for top/bottom. In font-size, it refers to the parent’s font size. Set the “Parent Size” configuration to match whichever dimension applies to your use case.