Favorite places of your favorite city
Home
Add to preferred sources on Google

CSS Unit Converter

Convert a CSS length between px, rem and em using the font sizes that apply to your CSS.

Length and context

−100,000 to 100,000, up to 6 decimal places. Use a dot or comma without grouping.

For lengths such as padding, rem uses the root’s computed font size and em uses the element’s own computed size.

Reference sizes

Editable assumption. Enter 0.01 to 1,000 with up to 4 decimal places.

Converted length

1.5 rem
1.5 rem

Element length

Root font size (px)
16 px

Check that the result is valid for your CSS property or media feature. Browser precision and supported ranges can vary.

Conversion details
  1. Divide by the target unit’s size in CSS pixels
    24 px ÷ 16 px/rem = 1.5 rem

Your draft can be restored in this tab after a refresh.

Convert a CSS length

  1. Enter a number and choose its unit and the target unit.
  2. Select where the value will be used and enter the relevant font sizes.
  3. Review the converted value and copy it into your stylesheet.

Choose the reference size

For an ordinary element length, rem uses the root font size and em uses the element's own computed font size.

When setting a non-root element's font size, em uses the parent's computed size.

In media queries both relative units use the browser's initial font size.

Work with spacing and breakpoints

At a 16 px root size, 24 px is 1.5 rem.

With a 20 px initial font size, a 640 px media query threshold is 32 em.

Conversion scope

The converter uses the font sizes you enter and works in CSS pixels.

Results use up to six decimal places. The intended CSS property determines which values are allowed.

Local calculation

The calculation runs in your browser. When browser storage is available, this tab restores the value, unit pair, CSS context, and all reference sizes, including those hidden in the current context. The result is recalculated from those inputs. Reset clears the saved draft and restores the defaults.

CSS units questions

16 px is a starting assumption. Use the computed root size for the document you are working on.

The reference size can change with the element and the property. Enter the computed size that applies to your case.

The result needed rounding to fit six decimal places. Copy uses that rounded value with CSS decimal syntax.

Use the browser's initial font size. The stylesheet's root font size does not set this reference.

Sources

The W3C specifications define the reference sizes and numeric rules used here.

Reviewed 20 November 2026.

The converter uses supplied font sizes and CSS pixels. Root font-size declarations, device pixels and other units are outside its scope.

CSS Filter Generator

Order and repeat CSS effects, compare a specimen and copy the exact filter declaration.

Open tool — CSS Filter Generator

Fluid Font Size Calculator

Create root-relative CSS from viewport endpoints and inspect the copied size model.

Open tool — Fluid Font Size Calculator

CSS Button Generator

Style native button states, inspect keyboard focus and copy HTML and CSS.

Open tool — CSS Button Generator

CSS Border Generator

Create borders with independent styles, widths, colors and opacity on all four sides.

Open tool — CSS Border Generator

npm Version Range Tester

Test a list of versions against one npm range, or compare which versions two ranges allow.

Open tool — npm Version Range Tester

CSS Specificity Calculator

Compare CSS selector scores and see which parts contribute to each tuple.

Open tool — CSS Specificity Calculator

CSS Background Pattern Generator

Create editable stripes, grids, dots and checkerboards. Preview colors and transparency locally, then copy the current CSS declarations.

Open tool — CSS Background Pattern Generator

CSS Clip Path Generator

Edit polygon points and basic shapes, preview the clipping and copy CSS.

Open tool — CSS Clip Path Generator

CSS Border Radius Generator

Edit eight corner radii, preview a box and copy CSS in pixels or percentages.

Open tool — CSS Border Radius Generator

CSS Grid Generator

Build a bounded CSS Grid example with editable tracks, placement and named areas. Preview it, copy CSS or HTML and download the same standalone example.

Open tool — CSS Grid Generator

CSS Flexbox Generator

Build a Flexbox example with container and item controls, explicit layout axes, matching CSS and HTML, and a local complete-example download.

Open tool — CSS Flexbox Generator

CSS Text Shadow Generator

Build ordered text shadows, preview plain text and copy exact CSS.

Open tool — CSS Text Shadow Generator

CSS Transform Generator

Compose repeatable 2D CSS transforms, edit px or percentage translation and origin, inspect a reference box and copy the exact current declarations.

Open tool — CSS Transform Generator

CSS Cubic Bezier Generator

Edit CSS cubic-bezier curves with coordinates, visual handles and presets. Inspect overshoot, run a deliberate comparison with linear motion, and copy easing CSS.

Open tool — CSS Cubic Bezier Generator

CSS Box Shadow Generator

Create ordered CSS box-shadow layers with a live preview and copyable code.

Open tool — CSS Box Shadow Generator

HTML to Markdown

Convert pasted or local HTML into Markdown, review conversion notes, and copy or download the result.

Open tool — HTML to Markdown

JavaScript Regex Tester

Test a JavaScript pattern locally and inspect matches, captures, and UTF-16 positions.

Open tool — JavaScript Regex Tester

Markdown Outline Extractor

Find Markdown headings, check their source lines and copy an indented outline.

Open tool — Markdown Outline Extractor

Markdown to HTML

Convert a Markdown draft to an HTML fragment, inspect the source and inert preview, then copy or download it.

Open tool — Markdown to HTML

CSS Gradient Generator

Create linear or radial CSS gradients with editable colors, opacity and stops.

Open tool — CSS Gradient Generator

Color Converter

Convert supported sRGB HEX, RGB and HSL literals with alpha, explicit precision and current code Copy.

Open tool — Color Converter

HTML Entity Encoder/Decoder

Encode or decode literal HTML references with explicit context, Unicode options and LF output, without parsing or rendering markup.

Open tool — HTML Entity Encoder/Decoder

Markdown Table Generator

Edit a small literal-text table, set alignment and copy GFM Markdown or import tab-separated text.

Open tool — Markdown Table Generator

HTML Table Generator

Build a rectangular table with captions and headers, then copy HTML and CSS.

Open tool — HTML Table Generator
View all tools in this category