skew()

Term side of the Card.
Topic: Transformations
Unit title: skew()
Categories: Function
Explanation side of the Card

Explanation: The function that skews an element along both the X and Y axes. This transformation distorts the shape of an element by slanting it, which can be used to create a sense of movement or perspective in the design.

Browser compatibility:
  • The chrome browser supports this feature starting from version 1.
  • The edge browser supports this feature starting from version 12.
  • The firefox browser supports this feature starting from version 3.5.
  • The safari browser supports this feature starting from version 3.1.
Availability: 

Example

Wrongcss
.tag {
  transform: skew(-15deg);
}
Rightcss
.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).

Analytics cookiesWe'd like to use analytics cookies to see which pages are useful. They're set only if you accept. Privacy Policy