skew()
Example
.tag {
transform: skew(-15deg);
}.tag { position: relative; isolation: isolate; }
.tag::before {
content: '';
position: absolute;
inset: 0;
z-index: -1;
background: var(--accent);
transform: skew(-15deg);
}Skewing only the background pseudo-element gives a slanted shape while the label text stays straight.
Common mistakes
- Skewing the button itself and getting slanted, hard-to-read text.
- Passing one value and expecting both axes to skew.
Key points
- Slanted backgrounds skew a pseudo-element or wrapper, so the text stays upright.
- If the parent is skewed, the child text is counter-skewed by the same angle.
- Angles have units, such as
skew(-15deg).
Interview questions
What does skew() with one value do?
It skews along the X-axis only, like skewX(). The second value, if given, skews along the Y-axis.
Is skew() the same as skewX() plus skewY()?
Not exactly. skew(a, b) is a single matrix, which differs from applying skewX(a) and then skewY(b).