CSS scale Property
The CSS scale property changes the visual size of an element along one or more axes without changing the space it occupies in the document layout.
It is an individual transform property that supports two-dimensional and three-dimensional scaling. You can enlarge, shrink, stretch, compress, or reflect elements independently of other transforms such as rotation and translation.
scale Syntax
The scale property accepts none or one, two, or three numeric or percentage scale factors.
Basic Syntax
selector {
scale: 1.2;
}
Available Values
.element {
scale: none;
}
.element {
scale: 1;
}
.element {
scale: 1.5;
}
.element {
scale: 0.75;
}
.element {
scale: 150%;
}
.element {
scale: 1.5 1;
}
.element {
scale: 1 0.5;
}
.element {
scale: 1 1 2;
}
.element {
scale: -1 1;
}
.element {
scale: calc(1 + 0.2);
}
CSS-Wide Keywords
.element {
scale: initial;
}
.element {
scale: inherit;
}
.element {
scale: unset;
}
.element {
scale: revert;
}
.element {
scale: revert-layer;
}
A single factor scales both horizontal and vertical dimensions equally. Two factors control the x-axis and y-axis independently. Three factors also specify scaling along the z-axis.
Property Values
| Value | Description |
|---|---|
none |
Applies no individual scaling transform. This is the initial value. |
<number> |
Scales the x-axis and y-axis equally using one numeric factor. |
<percentage> |
Specifies a scale factor as a percentage, where 100% represents the original size. |
<number-percentage> <number-percentage> |
Specifies separate horizontal and vertical scale factors. |
<number-percentage> <number-percentage> <number-percentage> |
Specifies scale factors for the x-axis, y-axis, and z-axis. |
calc() |
Calculates a numeric or percentage scale factor using a valid CSS math expression. |
initial |
Resets the property to none. |
inherit |
Uses the computed value from the parent element. |
unset |
Resets the property to none because it is not inherited. |
revert |
Reverts the property according to CSS cascade origin rules. |
revert-layer |
Reverts the property according to CSS cascade layer rules. |
Property Characteristics
| Characteristic | Value |
|---|---|
| Initial value | none |
| Inherited | No |
| Applies to | Transformable elements |
| Computed value | none or one, two, or three computed numeric scale factors |
| Animation type | By computed value, using transform interpolation |
| Percentages | Represent scale factors, with 100% equivalent to 1 |
Valid Values
.box {
scale: 1.25;
}
.box {
scale: 80%;
}
.box {
scale: 1.5 0.75;
}
.box {
scale: 1 1 2;
}
.box {
scale: -1;
}
Invalid Values
.box {
scale: 20px;
}
.box {
scale: auto;
}
.box {
scale: 1.5deg;
}
.box {
scale: 1, 2;
}
.box {
scale: 1 1 1 1;
}
Scale factors must be numbers or percentages. The property does not accept lengths, angles, comma-separated factors, or more than three factors.
How It Works
The scale property multiplies an element's visual dimensions by the specified scale factors.
A factor greater than 1 enlarges the element, a factor between 0 and 1 reduces its size, and a factor of 1 preserves its original dimensions.
Original Size
.box {
width: 120px;
height: 80px;
scale: 1;
}
The element remains visually 120 pixels wide and 80 pixels tall.
Enlarged Size
.box {
width: 120px;
height: 80px;
scale: 1.5;
}
The element appears 180 pixels wide and 120 pixels tall because both dimensions are multiplied by 1.5.
Reduced Size
.box {
width: 120px;
height: 80px;
scale: 0.5;
}
The element appears 60 pixels wide and 40 pixels tall.
Layout Space Remains Unchanged
Scaling changes the rendered appearance of an element but does not change its original layout dimensions or cause neighboring elements to reflow around its new visual size.
Important Distinction
Use scale for visual transformations. Use width, height, or layout properties when the actual space occupied by an element needs to change.
Uniform Scaling
Uniform scaling changes the horizontal and vertical dimensions by the same factor, preserving the element's proportions.
Enlarge an Element
.box {
scale: 1.5;
}
The element becomes 150% of its original visual size along both axes.
Shrink an Element
.box {
scale: 0.75;
}
The element becomes 75% of its original visual size.
Using Percentages
.box {
scale: 125%;
}
This is equivalent to scale: 1.25.
Preserve Original Size
.box {
scale: 1;
}
The element remains at its original visual size.
When to Use Uniform Scaling
Uniform scaling is useful for icons, illustrations, cards, and interactive elements that should grow or shrink without distortion.
Important Consideration
Scaling also changes the visual size of text, borders, and other rendered content within the transformed element.
Non-Uniform Scaling
Non-uniform scaling uses separate factors for the horizontal and vertical axes.
Horizontal Enlargement
.box {
scale: 1.5 1;
}
The element becomes 150% as wide while retaining its original height.
Vertical Enlargement
.box {
scale: 1 1.5;
}
The element becomes 150% as tall while retaining its original width.
Horizontal Compression
.box {
scale: 0.5 1;
}
The element becomes half as wide while retaining its original height.
Different Scale Factors
.box {
scale: 1.25 0.75;
}
The element becomes 125% as wide and 75% as tall.
Important Consideration
Non-uniform scaling changes an element's proportions and can distort text, images, and interface controls. Use it when intentional stretching or compression is appropriate.
Three-Dimensional Scaling
The scale property supports a third factor for scaling along the z-axis.
Basic Three-Dimensional Scaling
.box {
scale: 1 1 2;
}
The x-axis and y-axis remain unchanged, while the z-axis is scaled by a factor of 2.
Scaling All Three Axes
.box {
scale: 1.2 1.2 1.5;
}
The element is enlarged along the x-axis and y-axis, while its z-axis coordinates are scaled by a larger factor.
Using Perspective
.scene {
perspective: 600px;
}
.scene .box {
rotate: y 45deg;
scale: 1 1 2;
}
Perspective and rotation can make three-dimensional scaling more noticeable.
Preserving Three-Dimensional Space
.scene {
perspective: 600px;
}
.scene .group {
transform-style: preserve-3d;
}
.scene .box {
scale: 1 1 2;
}
The transform-style: preserve-3d declaration allows eligible descendants to participate in a shared three-dimensional rendering space.
Important Consideration
A flat element may show no obvious visual difference from z-axis scaling alone. The effect becomes more apparent when combined with three-dimensional transforms or descendants positioned at different depths.
Negative and Zero Values
The scale property accepts negative and zero factors, which produce effects beyond ordinary enlargement and reduction.
Horizontal Reflection
.box {
scale: -1 1;
}
The element is reflected horizontally across its vertical axis.
Vertical Reflection
.box {
scale: 1 -1;
}
The element is reflected vertically across its horizontal axis.
Reflecting Both Axes
.box {
scale: -1 -1;
}
The element is reflected along both axes, producing a visual result equivalent to a half-turn for ordinary two-dimensional content.
Scaling to Zero
.box {
scale: 0;
}
The element collapses visually to its transform origin, although it remains in the document and retains its original layout space.
Scaling One Axis to Zero
.box {
scale: 0 1;
}
The element collapses horizontally while retaining its vertical scale.
Important Consideration
A visually collapsed element can still exist in the accessibility tree and may remain keyboard-focusable. Do not rely on scale: 0 to hide interactive content from users or assistive technologies.
Changing the Scaling Origin
The transform-origin property controls the point from which an element scales.
For many HTML elements, the default transform origin is the center.
Scale From the Center
.box {
scale: 1.5;
transform-origin: center;
}
The element expands outward from its center.
Scale From the Top-Left Corner
.box {
scale: 1.5;
transform-origin: top left;
}
The element expands away from its top-left corner.
Scale From the Bottom-Right Corner
.box {
scale: 1.5;
transform-origin: bottom right;
}
The element expands away from its bottom-right corner.
Using Percentage Coordinates
.box {
scale: 1.5;
transform-origin: 25% 75%;
}
The scaling origin is positioned 25% across the element and 75% down from its top edge.
Using Length Values
.box {
scale: 1.5;
transform-origin: 20px 30px;
}
Important Consideration
Changing the transform origin affects the direction in which the element visually expands or contracts. It does not change the element's original layout dimensions.
scale Versus transform
The scale property is an individual transform property. The transform property can combine multiple transform functions in one declaration.
Using scale
.box {
scale: 1.5;
}
Using transform
.box {
transform: scale(1.5);
}
Both declarations can produce the same visual scaling when no other transforms are applied.
Combining Individual Transform Properties
.box {
translate: 20px 10px;
rotate: 15deg;
scale: 1.2;
}
Each individual transform property can be declared and animated independently.
Combining scale With transform
.box {
scale: 1.2;
transform: translateX(30px);
}
Both transformations apply. Individual transform properties are composed before the transformations specified by transform.
Transform Order
Individual transforms are composed in a defined order: translation, rotation, scaling, and then the transform property.
When to Use scale
Use scale when the visual size of an element should be controlled or animated independently of its other transformations.
When to Use transform
Use transform when a specific sequence of transform functions is needed or when supporting older browsers without individual transform properties.
Animating Scale
The scale property supports CSS transitions and keyframe animations.
Hover Enlargement
.button {
scale: 1;
transition: scale 0.25s ease;
}
.button:hover {
scale: 1.1;
}
The button grows to 110% of its original visual size when hovered.
Hover Reduction
.card {
scale: 1;
transition: scale 0.3s ease;
}
.card:hover {
scale: 0.95;
}
The card becomes slightly smaller when hovered.
Pulsing Animation
.pulse {
animation: pulse-scale 1.5s ease-in-out infinite;
}
@keyframes pulse-scale {
0%, 100% {
scale: 1;
}
50% {
scale: 1.15;
}
}
The element repeatedly grows and returns to its original size.
Entrance Animation
.entrance {
animation: scale-in 0.4s ease-out both;
}
@keyframes scale-in {
from {
scale: 0.8;
opacity: 0;
}
to {
scale: 1;
opacity: 1;
}
}
The element appears to grow into place while fading in.
Respecting Reduced Motion Preferences
@media (prefers-reduced-motion: reduce) {
.button,
.card {
transition: none;
}
.pulse,
.entrance {
animation: none;
}
}
This disables the scaling animations and transitions for users who request reduced motion.
Important Consideration
Large or repeated scaling animations can be distracting. Keep motion subtle and avoid scaling interactive elements so much that they overlap nearby controls.
scale Example
The following example compares the original size of an element with enlarged, reduced, and non-uniform scaling.
HTML Example
<div class="scale-demo">
<div class="scale-item">scale: 1</div>
<div class="scale-item scale-large">scale: 1.25</div>
<div class="scale-item scale-small">scale: 0.75</div>
<div class="scale-item scale-wide">scale: 1.3 0.8</div>
</div>
CSS Example
.scale-demo {
display: grid;
grid-template-columns: repeat(2, minmax(0, 1fr));
gap: 40px 25px;
padding: 35px 20px;
background-color: #f1f5f9;
border: 1px solid #cbd5e1;
}
.scale-demo .scale-item {
display: flex;
align-items: center;
justify-content: center;
min-height: 75px;
padding: 10px;
background-color: #2563eb;
color: #ffffff;
font-weight: bold;
text-align: center;
box-sizing: border-box;
}
.scale-demo .scale-large {
scale: 1.25;
}
.scale-demo .scale-small {
scale: 0.75;
}
.scale-demo .scale-wide {
scale: 1.3 0.8;
}
The first box retains its original size. The second grows by 25%, the third shrinks to 75%, and the fourth becomes wider while decreasing in height.
Increasing the Scale
.scale-demo .scale-large {
scale: 1.5;
}
The enlarged box becomes 150% of its original visual size.
Scaling From a Corner
.scale-demo .scale-large {
transform-origin: top left;
}
The box now expands away from its top-left corner instead of its center.
Using a Percentage
.scale-demo .scale-small {
scale: 60%;
}
The reduced box becomes 60% of its original visual size.
Accessibility Considerations
Scaling can improve visual emphasis, but transformed elements must remain readable, accessible, and usable.
Maintain Readable Text
Avoid reducing text to a size that makes it difficult to read. Scaling text visually does not change its underlying font-size value.
Preserve Usable Controls
Interactive elements should remain large enough to identify and activate. Avoid shrinking buttons and links excessively.
Avoid Overlapping Content
Enlarged elements may extend beyond their original layout boxes and cover neighboring content.
Maintain Visible Focus Indicators
Keyboard focus indicators should remain visible when an element is scaled or animated.
Respect Reduced Motion Preferences
Use prefers-reduced-motion to reduce or disable unnecessary scaling animations.
Avoid Hiding Content With scale: 0
An element scaled to zero may remain in the accessibility tree and keyboard navigation order. Use appropriate visibility or display controls when content must actually be hidden.
Support Zoom and Reflow
Test scaled elements at increased browser zoom levels and narrow viewport widths to ensure important content remains accessible.
Important Consideration
The scale property changes visual dimensions only. It does not change semantic meaning, reading order, or the original space reserved in document layout.
Common Mistakes
Using Length Values
.box {
scale: 20px;
}
Scale factors must be numbers or percentages, not lengths.
Using Commas Between Factors
.box {
scale: 1.5, 0.75;
}
Separate multiple scale factors with spaces, not commas.
Confusing scale With the scale() Function
.box {
scale: scale(1.5);
}
The scale property accepts factors directly. The scale() function belongs inside the transform property.
Expecting Layout Dimensions to Change
Scaling an element does not change the original space it occupies in normal document flow.
Using Non-Uniform Scaling on Text
Different horizontal and vertical factors can distort text and make it difficult to read.
Ignoring the Transform Origin
The default transform origin is normally the center for many HTML elements. Use transform-origin when scaling should expand from another point.
Assuming scale and transform Are Interchangeable in Every Case
Individual transform properties use a defined composition order, which can differ from the order of functions in a transform declaration.
Using scale: 0 to Hide Interactive Content
Visually collapsed elements may remain focusable and accessible to assistive technologies.
Ignoring Reduced Motion Preferences
Repeated scaling animations should provide an appropriate reduced-motion alternative.
Important Considerations
Keep the following points in mind when using scale:
- It is an individual CSS transform property.
- Its initial value is
none. - The property is not inherited.
- It applies to transformable elements.
- A single factor scales both the x-axis and y-axis equally.
- Two factors control horizontal and vertical scaling independently.
- Three factors control scaling along the x-axis, y-axis, and z-axis.
- A factor of
1preserves the original dimension. - A factor greater than
1enlarges the element along the specified axis. - A factor between
0and1reduces the element along the specified axis. - Negative factors can reflect an element.
- A factor of
0collapses the element visually along the corresponding axis. - Scale factors can be numbers or percentages.
100%is equivalent to a scale factor of1.- Length and angle values are invalid.
- Multiple scale factors are separated by spaces.
- The
transform-originproperty controls the scaling origin. - For many HTML elements, the default transform origin is the center.
- Scaling changes visual dimensions without changing normal layout space.
- Scaled elements can overlap nearby content.
- Scaling also affects the visual size of text and borders.
- Three-dimensional scaling can be combined with perspective and rotation.
- Individual transform properties can be animated independently.
- Translation, rotation, scaling, and the
transformproperty follow a defined composition order. - The
scale()function is used inside thetransformproperty. - Scaling animations can use transitions or keyframes.
- Respect reduced-motion preferences when animating scaling.
- Do not rely on
scale: 0to hide interactive content accessibly. - Test scaled layouts at different viewport sizes and zoom levels.
Browser Support
The CSS scale property is Baseline Widely available and is supported in current versions of major browsers.
The individual scale property is newer than the scale() transform function. Older browsers may support transform: scale() without supporting the standalone scale property.
For current compatibility information, visit Can I Use? and search for scale.
When supporting older browsers, consider using transform: scale() as a fallback where appropriate.
Specifications
The scale property is defined in CSS Transforms Module Level 2.
The specification defines individual transform properties, scale factors, interpolation, and how individual transforms are composed with the transform property.
For additional documentation and examples, consult MDN Web Docs.
