CSS scaleX()
Published Aug 29, 2025
Contribute to Docs
In CSS, The scaleX() function in CSS is used to apply a scaling transformation to an element along the X-axis. This means that the element will be stretched or compressed horizontally.
Syntax
transform: scaleX(s);
Parameters:
s: A number that specifies the scaling factor. A value of1means no scaling, values greater than1enlarge the element, values between0and1reduce its size, and negative values flip the element horizontally.
Example
In this example, the element with the class bigCat will be scaled to twice its original width:
The CSS code is:
.regularSizeCat {transform: scaleX(1);}.bigCat {transform: scaleX(2);}
The HTML code is:
<html><head> </head><body style="background-color: #020617;"><p>Regular Cat</p><img class="regularSizeCat" src="cat.jpg" alt="Regular Size Cat" /><p>Scaled-X Cat</p><img class="bigCat" src="cat.jpg" alt="Big Cat" /></body></html>

Contribute to Docs
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.
Learn CSS on Codecademy
- Front-end engineers work closely with designers to make websites beautiful, functional, and fast.
- Includes 34 Courses
- With Professional Certification
- Beginner Friendly.115 hours
- In this CSS tutorial, you’ll learn how to add CSS to visually transform HTML into eye-catching sites.
- Beginner Friendly.6 hours