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.
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.
Click any card to copy the value.
Paste CSS and convert every value that uses one unit into another, for example all px values into rem. The settings from the converter tab are used for the base values.
Create a fluid font size that grows smoothly between two viewport widths. The result uses a rem value plus a vw value, so text still responds to the user's font size settings.
clamp(1rem, 0.8333rem + 0.8333vw, 1.5rem)
The quick brown fox jumps over the lazy dog.
Check the size of a button, link or other control against WCAG 2.2 target size guidance. Sizes are in CSS pixels.
All conversions run inside your browser. We never send, save or store the values or the CSS you enter.
Type a number and choose the unit you are converting from and to.
Set the root font size, parent font size and viewport size if they differ from the defaults.
Copy one value, or convert a whole stylesheet or a fluid font size.
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.
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.
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.
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.
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.
You can convert any CSS unit in a few clicks.
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.
| Pixels | rem | em (16px parent) | Points | Percent |
|---|---|---|---|---|
| 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% |
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.
There is no single best unit, but each one has a clear job. This comparison helps you choose.
| Unit | Relative to | Best for | Watch out for |
|---|---|---|---|
| px | CSS reference pixel (fixed) | Borders, shadows, hairlines and very small details | Does not follow a change of the browser's default font size |
| rem | Root (html) font size | Font sizes, spacing, layout widths and media queries | Changing the root size changes everything that uses rem |
| em | Font size of the element or its parent | Spacing that should scale with a component's text size | Nested elements compound, so sizes can grow or shrink unexpectedly |
| % | Depends on the property | Widths, heights and fluid layouts | The base differs per property and per parent |
| vw, vh | Viewport width or height | Full-screen sections and fluid layout pieces | Mobile 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.
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.
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 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.
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.
| Unit | Equals | In pixels |
|---|---|---|
| 1in | 2.54cm = 25.4mm = 72pt = 6pc | 96px |
| 1cm | 10mm = 40Q | 37.7953px |
| 1mm | 4Q | 3.7795px |
| 1Q | 0.25mm | 0.9449px |
| 1pt | 1/72in | 1.3333px |
| 1pc | 12pt | 16px |
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.
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 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.
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.
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.
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.
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.
Quick answers to common questions about converting px to rem, em and other CSS units.
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.
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.
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.
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.
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.
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.
No. All conversions run in your browser, and nothing you enter is uploaded, saved or shared.
Merge, split, compress and convert files in seconds. Explore powerful free tools for all your everyday needs.
Explore All Tools →