CSS Unit Converter
Convert between CSS units including px, pt, rem, em, vw, and vh using your screen DPI, base font size, and viewport width.
CSS Unit Converter
Calculator
Adjust values & calculateEnter your values below. Every result is computed in your browser — no data is sent to any server.
Formula: px = pt × DPI/72 | rem = px/baseFontPx | vw = px/(viewportWidth/100)
Worked example — 12pt = 1rem
Formula
px = pt × DPI/72 | rem = px/baseFontPx | vw = px/(viewportWidth/100)
CSS units convert based on DPI (96 for web), base font size for rem/em, and viewport for vw/vh.
Worked Examples
Example 1: 16px
Problem:Convert 16px at 96 DPI
Solution:16×72/96=12pt, 16/16=1rem
Result:12pt = 1rem
Frequently Asked Questions
Why does 1px not equal 1pt?
Points (pt) are 1/72 of an inch. At web standard 96 DPI, 1px = 0.75pt. They only equal at 72 DPI.
When should I use rem instead of px in CSS?
Rem (root em) units are relative to the root HTML element font size (typically 16px), and they are strongly preferred over px for font sizes and layout spacing in modern web development. Using rem instead of px allows users who have set a larger default font size in their browser preferences to have that preference respected throughout your site, improving accessibility. It also makes responsive scaling easier — changing the root font size scales all rem-based elements proportionally. Px is still appropriate for fixed-size decorative elements, borders, and cases where you explicitly do not want the size to scale with user preferences.
What is the difference between em and rem in CSS?
Em units are relative to the font size of the current element's parent, which can cause compounding issues in nested elements. For example, if a parent has font-size: 1.5em and a child also has font-size: 1.5em, the child ends up at 2.25× the base size. Rem (root em) is always relative to the root HTML element, avoiding the compounding problem. This makes rem much more predictable and maintainable for typography and spacing systems. A common pattern is to set the root font size to 62.5% (making 1rem = 10px for easier mental math), though this can conflict with user accessibility settings.
When should I use vw and vh CSS units?
Viewport units (vw for viewport width, vh for viewport height) are relative to the browser window size and are useful for creating truly responsive layouts. Common uses include full-screen sections (height: 100vh), fluid typography that scales with screen size (font-size: 5vw), ensuring a sidebar takes exactly 30% of the viewport regardless of screen size, and creating sticky headers or footers. A caveat with vh on mobile browsers is that the browser chrome (address bar) causes 100vh to be larger than the visible area — using dvh (dynamic viewport height) or min() functions addresses this. Viewport units work best when combined with clamp() for responsive typography with minimum and maximum size constraints.
What is the CSS reference pixel and why is 96 the standard figure?
CSS does not measure the screen; it fixes an anchor. One inch is defined as exactly 96 px, which pins 1 px at 0.75 pt and about 0.2646 mm whatever the hardware does. The reference pixel is specified as a visual angle near 0.0213 degrees, roughly what a pixel subtended on a typical arm-length monitor when the rule was written. Because the ratio comes from the specification, changing the DPI field here reinterprets a measurement for output such as print rather than for browser rendering.
How do px, pt, pc, in, cm and mm relate in CSS?
Every absolute unit is defined against the inch, so the chain is fixed: 1 in = 96 px = 72 pt = 6 pc = 2.54 cm = 25.4 mm. That makes 1 pt equal to four thirds of a pixel, 1 pc equal to 16 px, and 1 cm equal to about 37.8 px. The quarter-millimetre unit Q, used in Japanese typography, is one fortieth of a centimetre or roughly 0.945 px. A 16 px body size is therefore exactly 12 pt, which is why those two figures line up in the example above.
What do the ch and ex units measure?
Both are font-relative. One ch is the advance width of the digit zero in the current font and one ex is the x-height, the height of a lowercase x. They track the typeface instead of an arbitrary number, which makes ch the natural unit for line length: a max-width near 65ch keeps a paragraph close to a comfortable measure at any font size. In a proportional face ch only approximates one character, since letters differ in width, and both units shift if a webfont fails to load.
How does calc let me mix units in one value?
calc evaluates its expression at used-value time, so it can combine units that are not resolved until layout: width: calc(100% - 2rem) gives a full-width box inset by a fixed margin, and height: calc(100vh - 4rem) gives a panel sitting under a fixed header. Percentages inside it still resolve against the containing block, so meaning depends on the parent. The syntax trap is whitespace, because the plus and minus operators need a space on both sides or the whole declaration is discarded.
Which unit should a media query breakpoint use?
Media queries accept px, em and rem, but font-relative units inside a query are evaluated against the browser initial font size rather than any font-size you declared on the html element. That is useful rather than annoying: a reader who raises the default from 16 px to 20 px pushes every em-based breakpoint outward by a quarter, so the layout switches to a roomier arrangement exactly where their larger text needs it. Pixel breakpoints stay fixed and ignore that preference entirely.
Why does a 3x phone screen still lay out at 96 CSS pixels per inch?
The CSS pixel is a layout unit, not a hardware one. On a high-density display the browser maps one CSS pixel onto a block of device pixels, a factor reported as window.devicePixelRatio, so a 3x phone paints a 1 px border across three device pixels and simply renders text more finely. Layout, media queries and every value this converter produces stay in CSS pixels. Only raster assets need to care, which is why images carry srcset with 2x and 3x descriptors.
Background & Theory
History
Reviewed for accuracy by Daniel Agrici, Founder & Lead Developer · Editorial policy
Related Calculators
🧮Epoch Timestamp Converter Calculator
Calculate epoch timestamp converter with inputs, formulas, and instant results.
🧮Timezone Offset Converter Calculator
Calculate timezone offset converter with inputs, formulas, and instant results.
🧮Hex Binary Converter
Calculate hex binary converter with interactive inputs and clear steps.
🧮RGB to CMYK Converter
Calculate rgb to cmyk converter with interactive inputs and clear steps.
🧮RGB HSL HSV Converter
Calculate rgb hsl hsv converter with interactive inputs and clear steps.
🧮Hex Color Converter (HEX, RGB, HSL)
Calculate hex color converter with inputs, formulas, and instant results.
🧮File Size Converter
Calculate file size converter with inputs, formulas, and instant results.
🧮Tailwind CSS Class Calculator
Convert pixel values to Tailwind CSS spacing, sizing, and font classes.