Skip to main content

CSS Unit Converter

Convert between px, rem, em, vw, vh, %, and pt.

How it works

  1. 1

    Enter design values

    Input your dimensions, color values, or CSS units into the tool.

  2. 2

    See instant conversion

    Review the converted design values and visual preview where available.

  3. 3

    Apply in your project

    Copy the final values into your stylesheet, design file, or component.

Common use cases

  • px to rem

    24px (base: 16px)

  • rem to px

    2rem (base: 16px)

About This Tool

Convert CSS units bidirectionally between px, rem, em, vw, vh, %, and pt. Configure the base font size (default 16 px) and viewport dimensions for accurate vw/vh/% conversions. This tool is essential for any front-end developer working with responsive layouts, design systems, or accessibility-compliant stylesheets.

Unit guidance: Use rem for font sizes and spacing to respect user accessibility preferences. Use em for component-relative sizing. Use vw/vh for viewport-responsive layouts. Use px for borders, shadows, and fine details that should not scale. Use pt when translating between design tools and CSS.

Understanding each CSS unit is critical for building maintainable and scalable stylesheets. Pixel values (px) are absolute and do not scale with user preferences, making them suitable only for fixed-dimension properties like borders, outlines, and box shadows. Root em values (rem) are relative to the root element font size, which defaults to 16 px in most browsers but can be overridden by user settings. This makes rem the preferred unit for font sizes, padding, and margin because it respects accessibility preferences. Element em values (em) are relative to the current element inherited font size, which makes them useful for component-level scaling where child elements should proportionally resize with their parent.

Viewport units (vw and vh) are relative to the browser viewport dimensions. One vw unit equals one percent of the viewport width, and one vh unit equals one percent of the viewport height. These units are powerful for hero sections, full-screen layouts, and typography that scales with the viewport. However, they can cause issues on mobile devices where the viewport changes when the address bar appears or disappears, so test thoroughly.

Percentage units (%) are relative to the parent element dimension. They work differently for horizontal vs vertical percentages: width percentages are relative to the parent width, but height percentages are relative to the parent height only if the parent has an explicit height set. This is a common source of confusion.

Point units (pt) come from the print world, where 1 pt equals 1/72 of an inch. In CSS, 1 pt is defined as exactly 1.333 px (16 px / 12 pt). Design tools like Figma and Photoshop often use pt, so converting between pt and px/rem is common during design handoff.

Tips for responsive design: Use a 4 px or 8 px spacing scale in rem for consistent spacing. For example, 0.25 rem (4 px), 0.5 rem (8 px), 0.75 rem (12 px), 1 rem (16 px). This creates a predictable spacing system that scales with the root font size. Combine clamp() with rem values for fluid typography: clamp(1 rem, 2.5vw, 2 rem) sets a minimum, preferred, and maximum font size.

Common conversion pitfalls: Remember that em values compound — nesting elements with em-based font sizes creates a multiplicative effect. A 0.875 em font inside another 0.875 em font results in 0.765625 em relative to the root. This is why rem is generally preferred for global sizing, while em is reserved for component-scoped scaling.

More examples

Examples

px to rem

Input

24px (base: 16px)

Output

1.5rem

rem to px

Input

2rem (base: 16px)

Output

32px
Frequently Asked Questions
What is the difference between rem and em?
rem is relative to the root font size (usually 16px). em is relative to the parent element font size. rem is more predictable for consistent sizing across nested elements because it does not compound, whereas em values multiply in nested contexts.
What is the default base font size?
The browser default is 16px for the root element. You can change this in the tool to match your project settings. Many design systems override this with html { font-size: 62.5%; } to make 1rem equal 10px for easier mental math.
When should I use rem vs px?
Use rem for font sizes and spacing (respects user font preferences for accessibility). Use px for borders, shadows, and fine details that should not scale. A good rule of thumb is rem for anything that should adapt to user settings, and px for decorative or structural values.
How do viewport units (vw, vh) work?
1vw equals 1% of the viewport width and 1vh equals 1% of the viewport height. A font size of 5vw on a 1440px wide viewport computes to 72px. Be careful on mobile — viewport height can change when the browser chrome appears or disappears.
Why does the 62.5% root font size trick exist?
Setting html { font-size: 62.5%; } makes 1rem equal 10px (since 16px × 62.5% = 10px). This simplifies calculations — 1.4rem becomes 14px instead of needing to divide by 16. However, this approach has accessibility trade-offs because it overrides user font size preferences by effectively reducing the base size.
What is the relationship between pt and px?
1pt equals approximately 1.333px (or exactly 96/72 px). In CSS, 12pt = 16px. Point units are primarily used when translating print designs or working with design tools that default to pt measurements.
Can I use this tool for responsive typography?
Yes. Convert your desired pixel sizes to rem or vw units, then use CSS clamp() to create fluid typography scales. For example, clamp(1rem, 2.5vw, 1.5rem) smoothly scales between a minimum and maximum size based on the viewport width.
How do percentage (%) units work in CSS?
Percentage units are relative to the parent element. Width percentages reference the parent width, but height percentages only work if the parent has an explicit height set. This is why height: 100% often fails — the parent may not have a defined height.

Learn More

Related Guides

Discover More Tools

View all Design Tools →