Free ToolsGuidesCase StudiesResourcesAboutContact
Get Your Free AI Automation Audit Book a Free 30-Minute Strategy Call
Playground~/frontend Open editor

~/frontend-tools/css-unit-converter

CSS Unit Converter

ToolRuns in your browserNothing is uploadedFree · no sign-up

Convert a length between every common CSS unit at once. Set the context that relative units depend on, the root font size, parent font size, parent width and viewport size, and see the value in px, rem, em, %, physical units and viewport units side by side.

Context for relative units

    Using the CSS Unit Converter

    Absolute units

    In CSS, absolute units are fixed ratios of the pixel: 1in is 96px, 1cm is about 37.8px, 1pt is 1/72 of an inch and 1pc is 12pt. On screens they do not match real-world sizes exactly, so use them mainly for print stylesheets.

    Relative units

    rem is relative to the root font size, em to the parent element's font size, and % depends on the property: for widths it is the parent's width, for font size the parent's font size. That is why the converter asks for this context.

    Viewport units

    1vw is 1% of the viewport width and 1vh is 1% of the viewport height; vmin and vmax use the smaller or larger of the two. On mobile, the dynamic units dvh and svh account for browser toolbars that appear and disappear.

    Picking a unit

    Use rem for type and spacing so text scales with user settings, % or fr for fluid layout widths, viewport units sparingly for full-screen sections, and px for thin borders and fine details.

    What is the difference between em and rem?

    rem is relative to the root font size, so 1rem is the same everywhere on the page. em is relative to the font size of the element itself (or its parent, for font-size), so it changes inside elements with a larger or smaller font. rem is predictable for spacing; em is useful when something should scale with its own text, such as a button's padding.

    Worked example: viewport units on phones

    100vh on a phone can be taller than the visible screen because of the browser's address bar. The newer units svh, lvh and dvh measure the small, large and dynamic viewport. Enter your viewport height in the context boxes to work out what the viewport units come to in pixels.

    Frequently asked questions

    Why does % show a different number for font size?

    Percent for a width is based on the parent width; the converter assumes a length such as width or margin. For font size, % behaves like em.

    Is 1pt the same as 1px?

    No. 1pt is 1.333px in CSS.

    Are the results rounded?

    To four decimal places, which is far finer than a screen can show.

    What does 1in equal in CSS?

    CSS defines 1 inch as exactly 96 pixels, 1cm as about 37.8 pixels and 1pt as 1/72 of an inch, or 1.333 pixels. These are fixed ratios, not the physical size on your screen.

    Which unit is best for font sizes?

    rem is the usual choice because it respects the visitor's browser font setting while staying consistent across the page.