CSS Reference ยท Scrolling, Interaction and UI
The zoom property
Reference for the CSS zoom property: scale an element and its layout footprint, how it differs from transform: scale(), and what to watch out for.
The zoom property scales an element and everything inside it, like a magnifying glass that also changes the space the element takes up. A box with zoom: 2 is drawn twice as large and its neighbors move out of the way.
For many years zoom was a non-standard feature that originated in old Internet Explorer and was copied by WebKit and Blink-based browsers. It has since been written into a specification and is now implemented more widely, so it is reasonable to use in current browsers. Check a compatibility table if you must support older ones.
.preview { zoom: 1.5; }
Try it
Syntax
zoom: normal | <number> | <percentage>
- Initial value:
normal(the same as1) - Applies to: all elements
- Inherited: no, but the effect applies to all descendants because they are scaled with the element
- Animatable: yes, as a number
- Computed value: the number or percentage converted to a number, or
normalas1
Values
| Value | Description |
|---|---|
normal |
No zoom; same as 1 or 100%. |
<number> |
A scale factor. 2 doubles the size, 0.5 halves it. Negative values are invalid. |
<percentage> |
The same factor written as a percentage: 150% is 1.5. |
Usage notes
- Layout follows the zoom. Unlike
transform: scale(), a zoomed element takes up its scaled space, wraps text at the scaled width and pushes neighbors. Usetransformwhen you want a purely visual effect, such as a hover effect, because transforms do not cause reflow. - Zoom compounds. Nested elements with their own
zoommultiply: azoom: 2inside azoom: 2renders at four times. - Lengths are scaled, not rewritten. A
width: 100pxinside azoom: 2box is 200 CSS pixels on screen. Viewport units and media queries are not changed by element zoom. - Measurements may confuse scripts. Values from methods like
getBoundingClientRect()and pointer coordinates can differ between engines and from your expectations when elements are zoomed. Test anything that depends on pixel math. - Not the browser zoom. This property is separate from the user's browser zoom (Ctrl and plus). Do not use it to override a user's zoom level or to make text bigger as a replacement for
font-sizeand theremunit, which respect user preferences better. - Avoid it for responsive layouts. Layout built with
zoomhides the real sizes in the style sheet. Prefer normal sizing,clamp()and container units. - Good fits. Scaling a third-party widget or legacy fixed-size content, or scaling a preview thumbnail of a page.
Browser support
Supported in current versions of all major browsers, though it was non-standard for many years, so older versions of some browsers lack it; check a compatibility table for the range you need.