Skip to content
⚠ TESTING ENVIRONMENT You are viewing a testing copy of Tolioo. Changes here do not affect the live website.

CSS Unit Converter

Convert px to rem, em, vw, pt, percent and every other CSS unit instantly. Convert whole stylesheets, build fluid typography with clamp() and check touch target sizes. Fast, free and no signup.

  • 100% free
  • No Signup
  • 14 CSS units
1.5rem
24px = 1.5rem
Conversion settings (base values)
For rem. Browser default is 16px.
For em.
What the percent refers to.

All units

Click any card to copy the value.

Your Privacy Matters

All conversions run inside your browser. We never send, save or store the values or the CSS you enter.

ADVERTISEMENT
Demo Ad 728 x 90

How to convert CSS units

1Enter a value

Type a number and choose the unit you are converting from and to.

2Check your base values

Set the root font size, parent font size and viewport size if they differ from the defaults.

3Copy the result

Copy one value, or convert a whole stylesheet or a fluid font size.

CSS UNITS GUIDE

CSS Unit Converter – Convert px to rem, em, vw, pt and Every Other CSS Unit

Need to convert px to rem, rem to px, px to em, pt to px or px to vw in a hurry? This free CSS unit converter does it instantly, and it does much more than a simple calculator. Enter a value, pick the unit you are converting from and to, and see the result in all 14 common CSS units at once: px, rem, em, percent, pt, pc, in, cm, mm, Q, vw, vh, vmin and vmax. Set your own root font size, parent font size and viewport size so the answer matches your real project, not a fixed 16px assumption. You can also paste a whole stylesheet and convert every px value to rem in one click with the CSS batch converter, build a fluid typography value with a clamp() calculator, and check whether a button or link meets the WCAG 2.2 touch target size guidance. It is built for web developers, front-end engineers, designers and anyone who works on responsive, accessible websites, and it needs no signup, no plugin and no installation. Everything runs in your browser, so your values and your CSS stay private.

px to rem Converter and More

Convert between px, rem, em, percent, points, picas, inches, centimetres, millimetres, Q and the viewport units vw, vh, vmin and vmax with your own base values.

CSS Batch Converter

Paste a stylesheet and convert every px value to rem, em or any other unit in one step. A fast way to make an existing design scale with the user's font size.

Fluid Type and Accessibility Checks

Generate a clamp() font size that scales smoothly between two screen sizes, and check target sizes against WCAG 2.2, all in the same tool.

What Is a CSS Unit Converter?

A CSS unit converter is a tool that translates a length from one CSS unit into another. CSS offers many units for sizes, spacing, fonts and layout. Some are absolute, such as pixels, points, inches and centimetres. Others are relative, such as rem, em, percent and the viewport units. Moving a design from one unit to another by hand means remembering formulas and doing arithmetic for every value. A converter removes that work and reduces mistakes, especially when you convert many values or when the result depends on a base such as the root font size.

The most common conversion on the web is px to rem. Designers often hand over sizes in pixels, while developers are encouraged to write font sizes and spacing in rem so that interfaces respect the reader's preferred text size. A px to rem converter gives you the rem value for any pixel size in seconds, and a rem to px converter lets you check what a rem value will look like on screen.

How to Use the CSS Unit Converter

You can convert any CSS unit in a few clicks.

  1. Enter the value: Type the number you want to convert, for example 24.
  2. Choose the units: Pick the unit to convert from and the unit to convert to, or tap a quick button such as px → rem. Use the swap button to reverse the conversion.
  3. Set your base values: Open Conversion settings and enter your root font size, the parent font size for em, the parent size for percent and your viewport size. Leave the defaults if you use the standard 16px browser size.
  4. Read the result: The large result shows your conversion, and the All units grid shows the same length in every unit.
  5. Copy it: Click Copy result, or click any unit card to copy that value with its unit.

How to Convert px to rem

To convert px to rem, divide the pixel value by the root font size. The formula is rem = px ÷ root font size. Browsers set the default root font size to 16px, so 16px equals 1rem, 24px equals 1.5rem and 32px equals 2rem. If your page changes the root font size, use that value instead. For example, with a root font size of 20px, 40px equals 2rem. To go the other way, multiply the rem value by the root font size, so px = rem × root font size.

The chart below shows common px to rem conversions for the default 16px root, with em, points and percent for reference.

px to rem conversion chart (16px root font size)
Pixelsremem (16px parent)PointsPercent
8px 0.5rem 0.5em 6pt 50%
10px 0.625rem 0.625em 7.5pt 62.5%
12px 0.75rem 0.75em 9pt 75%
14px 0.875rem 0.875em 10.5pt 87.5%
16px 1rem 1em 12pt 100%
18px 1.125rem 1.125em 13.5pt 112.5%
20px 1.25rem 1.25em 15pt 125%
24px 1.5rem 1.5em 18pt 150%
28px 1.75rem 1.75em 21pt 175%
32px 2rem 2em 24pt 200%
36px 2.25rem 2.25em 27pt 225%
40px 2.5rem 2.5em 30pt 250%
48px 3rem 3em 36pt 300%
56px 3.5rem 3.5em 42pt 350%
64px 4rem 4em 48pt 400%
72px 4.5rem 4.5em 54pt 450%
80px 5rem 5em 60pt 500%
96px 6rem 6em 72pt 600%

How to Convert px to em and em to px

An em is relative to the font size of the element it is used on, or to the parent's font size when it is used for the font-size property itself. To convert px to em, divide the pixel value by the font size of the parent: em = px ÷ parent font size. To convert em to px, multiply: px = em × parent font size. If the parent font size is 16px, then 1.5em is 24px. If the parent is 20px, then 1.5em is 30px. That is why the converter has a separate parent font size setting.

px vs rem vs em: Which Unit Should You Use?

There is no single best unit, but each one has a clear job. This comparison helps you choose.

UnitRelative toBest forWatch out for
pxCSS reference pixel (fixed)Borders, shadows, hairlines and very small detailsDoes not follow a change of the browser's default font size
remRoot (html) font sizeFont sizes, spacing, layout widths and media queriesChanging the root size changes everything that uses rem
emFont size of the element or its parentSpacing that should scale with a component's text sizeNested elements compound, so sizes can grow or shrink unexpectedly
%Depends on the propertyWidths, heights and fluid layoutsThe base differs per property and per parent
vw, vhViewport width or heightFull-screen sections and fluid layout piecesMobile browser bars change viewport height

A widely used approach is to use rem for font sizes and most spacing, px for borders and fine details, em for components whose spacing should scale with their own text, and percent or modern layout tools such as Grid and Flexbox for widths.

What Is rem in CSS?

The rem unit stands for root em. It is always relative to the font size of the root element, which is the html element. Because it does not depend on parent elements, rem does not compound, which makes it predictable. A heading set to 2rem will have the same size wherever it appears, as long as the root font size is the same. Most browsers use 16px as the default root size, but users can change this default in their browser settings, and rem values will follow that change.

What Is em in CSS and Why Does It Compound?

The em unit is relative to the font size of the element it is used on. For the font-size property it refers to the parent's font size. This makes em useful for components, but it also means sizes multiply when elements are nested. If a list sets font-size to 1.2em and a nested list inside it does the same, the inner text is 1.2 × 1.2, or 1.44 times the original size. When you convert px to em, always think about which parent font size applies, and use the parent font size setting in the converter to match it.

Viewport Units: vw, vh, vmin, vmax, dvh, svh and lvh

Viewport units are relative to the size of the browser window. One vw is 1% of the viewport width, and one vh is 1% of the viewport height. The vmin unit is 1% of the smaller dimension, and vmax is 1% of the larger one. To convert px to vw, divide the pixel value by the viewport width and multiply by 100. For a 1440px wide viewport, 144px equals 10vw. Because the result depends on the viewport, the converter lets you set the width and height, or use your current screen size.

On mobile browsers, the address bar and toolbars can appear and disappear, which changes the visible height, so 100vh can be taller than the visible area. Newer viewport units solve this. The svh unit uses the smallest viewport, with browser bars shown, lvh uses the largest viewport, with the bars hidden, and dvh adapts dynamically as the bars change. Use them for full-height sections on mobile, and check browser support for your audience.

Absolute Units: in, cm, mm, Q, pt, pc and px

CSS defines fixed relationships between its absolute units, which is why they convert exactly. One inch equals 96 pixels and 2.54 centimetres. One point equals 1/72 inch, one pica equals 12 points, and one Q equals a quarter of a millimetre. A CSS pixel is a reference unit, not a physical screen pixel, so on a real screen an inch in CSS may not measure exactly one inch. These units are most useful for print stylesheets, where physical sizes matter.

UnitEqualsIn pixels
1in2.54cm = 25.4mm = 72pt = 6pc96px
1cm10mm = 40Q37.7953px
1mm4Q3.7795px
1Q0.25mm0.9449px
1pt1/72in1.3333px
1pc12pt16px

What Does Percent Mean in CSS?

A percentage in CSS is always relative to something, and what that something is depends on the property. A width in percent refers to the width of the containing block. A font-size in percent refers to the parent's font size. A padding or margin in percent refers to the width of the containing block, even for top and bottom values. Because the base changes, the converter uses a separate setting called parent size for percent. Set it to the size that your percentage refers to, such as 16px for a font size or the container width for a layout width.

Convert a Whole Stylesheet From px to rem

The CSS batch converter changes every value that uses one unit into another across a pasted block of CSS. Choose px as the source unit and rem as the target, paste your CSS and the converted code appears instantly, ready to copy. The tool uses the root font size from your settings, so the result matches your project. After converting, review the output. Keep borders and fine details in px if you prefer, and be careful with em and percent, because their results depend on context. In media queries, em and rem are both based on the browser's initial font size, not on a root font size set in your CSS, so a media query breakpoint written in em or rem behaves differently from one written in px when users change their default text size.

Fluid Typography With the CSS clamp() Function

Fluid typography makes text grow smoothly with the screen instead of jumping at breakpoints. The clamp() function takes three values: a minimum, a preferred value and a maximum. A common pattern sets the preferred value to a rem part plus a vw part, so the size scales with the viewport and stays within safe limits. The Fluid type tab calculates this for you from a minimum and maximum font size and a minimum and maximum viewport width.

For example, to grow from 16px at a 320px viewport to 24px at a 1280px viewport with a 16px root size, the generator returns clamp(1rem, 0.8333rem + 0.8333vw, 1.5rem). At 320px the preferred value equals 16px, at 1280px it equals 24px, and in between it scales linearly. Because the preferred value includes a rem part, text still responds when users change their default font size, which is not true for a size written only in vw.

CSS Units and Web Accessibility

Unit choices affect accessibility. Many people increase their browser's default text size or zoom pages so they can read comfortably. Zooming scales px, rem and em alike, but changing the default font size in browser settings only affects text sized with relative units such as rem, em and percent, not text fixed in px. Using rem for font sizes therefore respects a reader's preference, and it is the recommended way to write type for accessible sites.

The Web Content Accessibility Guidelines include Resize Text, which asks that text can be resized up to 200 percent without assistive technology and without losing content or functionality, and Reflow, which asks that content adapts to narrow viewports without two-dimensional scrolling. Avoid sizing text only in vw, avoid fixed heights that clip enlarged text, and test your pages at 200 percent zoom and with a larger default font size. Use unitless line-height values, such as 1.5, so line spacing scales with the text, and remember that users may apply their own text spacing.

Touch Target Size: WCAG 2.2 Guidance

Small buttons and links are hard to tap, especially for people with motor impairments and on touch screens. WCAG 2.2 includes Target Size (Minimum), which sets 24 by 24 CSS pixels as the minimum size for many targets at the AA level, with exceptions such as enough spacing around smaller targets and inline links within sentences. The stricter Target Size (Enhanced) at AAA level asks for 44 by 44 CSS pixels. The Touch target check tab compares your width and height with these numbers. Larger is usually better, and you can use rem so that targets also grow when users enlarge their text.

The 62.5% Trick: Should You Use It?

Some developers set the root font size to 62.5%, so that 1rem equals 10px with the default 16px browser size and conversion is simple mental arithmetic. Because the value is a percentage, it still follows the user's default font size, but it makes body text tiny unless you set it again, and it can confuse other developers and third-party components. Others prefer to keep the default root size and use a converter, which avoids the extra rule. Both approaches work if you apply them consistently, and you can set the root font size in this tool to match whichever one you use.

Common Mistakes When Converting CSS Units

  • Assuming the root font size is always 16px: Check whether your CSS or a framework changes it.
  • Forgetting that em compounds: Nested elements multiply their em values.
  • Using vw alone for font sizes: This can stop text from responding to zoom and font settings. Combine it with rem in clamp().
  • Converting borders to rem: Hairlines can become blurry or uneven, so px is often better for them.
  • Ignoring what percent refers to: The same percentage means different things for width, font-size and padding.
  • Treating a CSS pixel as a device pixel: On high-density screens, one CSS pixel covers several device pixels.
  • Rounding too early: Keep enough decimal places while calculating, then round in the final value.

Tips for Better Responsive and Accessible CSS

  • Use rem for type and spacing: It scales with the reader's preferred text size.
  • Keep px for fine details: Borders, outlines and shadows rarely need to scale.
  • Let layout tools do the work: Grid, Flexbox and percentages are more flexible than fixed widths.
  • Test with a larger default font size: Change the browser setting and see whether your layout still works.
  • Test at 200 percent zoom: Make sure nothing is cut off or overlaps.
  • Make controls easy to tap: Aim for generous touch targets, not only the minimum.
  • Document your base values: Note your root font size and breakpoints so the whole team converts the same way.

Who Uses a CSS Unit Converter?

  • Front-end developers: Convert design values to rem and build responsive layouts.
  • UI and UX designers: Translate pixel designs into relative units for handoff.
  • Accessibility specialists: Check text sizing and touch targets.
  • WordPress and theme developers: Update older px-based stylesheets.
  • Students and beginners: Learn how CSS units relate to each other.

Free CSS Unit Converter With No Signup

Our CSS unit converter is free to use with no registration, no watermark and no limits. All calculations run in your browser, so your values and your CSS stay on your device. It works on desktop, tablet and mobile, and it gives the same answers every time, so you can rely on it while you build.

ADVERTISEMENT
Demo Ad 300 x 250
COMMON QUESTIONS

Frequently Asked Questions About CSS Units

Quick answers to common questions about converting px to rem, em and other CSS units.

How do I convert px to rem?

Divide the pixel value by the root font size. With the default 16px root, 24px ÷ 16 = 1.5rem. Enter your value in the converter, choose px to rem, and set a different root font size if your project uses one.

What is the difference between rem and em?

Rem is always relative to the root (html) font size, so it is predictable. Em is relative to the font size of the element or its parent, so nested elements compound. Use rem for general sizing and em for spacing that should scale with a component's own text.

Should I use px, rem or em for font sizes?

Rem is generally recommended for font sizes because it respects the user's default font size setting, which supports accessibility. Use px for borders and fine details, and em where spacing should follow a component's text size.

What is the default font size, and what base does the converter use?

Browsers use a default root font size of 16px, so the converter starts with 16px for root, parent and percent values. You can change each base value in the Conversion settings, and users can also change their own default in browser settings.

How do I make fluid typography with clamp()?

Open the Fluid type tab and enter your minimum and maximum font sizes and viewport widths. The tool returns a clamp() value with a rem part and a vw part. Copy it into your font-size rule and test it at different widths and at 200 percent zoom.

Can I convert a whole CSS file from px to rem?

Yes. Use the CSS batch converter, paste your CSS, choose px as the source and rem as the target. Review the result afterwards, and keep fine details such as borders in px if you prefer.

Is my data saved or sent anywhere?

No. All conversions run in your browser, and nothing you enter is uploaded, saved or shared.

ADVERTISEMENT
Demo Ad 320 x 50

All Tools, One Place

Merge, split, compress and convert files in seconds. Explore powerful free tools for all your everyday needs.

Explore All Tools →