CKTIS / CSS
px — CSS pixel
px is an absolute CSS length unit. Its relationship to other absolute units is fixed: 96px = 1in. A CSS pixel does not necessarily correspond to one physical screen pixel.
Version: CSS modules; structured CSSWG indexes reconciled with pinned MDN BCD; Chromium 152 scope gate; usage example verified in isolated Chromium 157.0.8103.51
Syntax
<number>pxpx denotes a CSS pixel, a unit of the <length> type. Write the number immediately before the unit, without whitespace: 16px or 0.5px. Writing 16 px is invalid. Where a length is allowed, zero can generally be written as 0 instead of 0px; whether negative values are allowed depends on the property.
It is an absolute unit: 96px = 1in = 72pt. “Absolute” means fixed ratios between these units, not a guaranteed ruler-measured size on a screen. Unlike em and rem, px does not depend on font size.
A CSS pixel is not the same as a physical device pixel. Its mapping accounts for viewing conditions; page zoom can change its visible screen size. The unit's model is based on the reference pixel, defined by a visual angle.
The example sets width to 96px and height to 24px. The expected output describes CSS dimensions, not physical pixel counts.
Examples
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>px — CSS pixels</title>
<style>
.sample { width: 96px; height: 24px; background: teal; }
</style>
</head>
<body>
<div class="sample" aria-hidden="true"></div>
<script>
const size = getComputedStyle(document.querySelector('.sample'));
console.log(`width: ${size.width}; height: ${size.height};`);
</script>
</body>
</html>Result
width: 96px; height: 24px;
The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.