Skewing Elements with skew()
You'll learn how to distort elements along the X or Y axis, creating slanted, italic-like visual effects.
What Is Skewing?
Imagine taking a rectangular piece of paper and gently pushing one edge sideways while keeping the opposite edge fixed—the rectangle transforms into a parallelogram. That's exactly what CSS skewing does to your elements. Unlike rotate() which spins elements around a central point, skew() slants them along one or both axes, creating a sheared, italicized appearance.
The Skew Functions
CSS provides three skewing functions:
skewX(angle) – Slants an element horizontally along the X-axis. Positive angles tilt the element to the left at the top.
.skew-horizontal {
transform: skewX(20deg);
}
skewY(angle) – Slants an element vertically along the Y-axis. Positive angles tilt the element downward on the right side.
.skew-vertical {
transform: skewY(15deg);
}
skew(x-angle, y-angle) – Combines both horizontal and vertical skewing in one function.
.skew-both {
transform: skew(10deg, 5deg);
}
If you provide only one value to skew(), it applies to the X-axis only (Y defaults to 0).
Practical Uses
Skewing is perfect for creating dynamic headers, parallelogram-shaped buttons, perspective effects, or adding visual interest to image galleries. Small angles (5–20deg) create subtle, professional effects, while larger angles produce dramatic distortions.
Key Takeaway: Use skewX() and skewY() to distort elements along specific axes, or skew() to combine both—angles are in degrees, and subtle skews create modern, dynamic layouts.