Skip to main content

The CSS skewX() Function

Give skewX() an angle and the element leans along the X-axis by that amount.

Example

Here a 20-degree angle skews the <div> horizontally, on the X-axis.

Prompt
Create a page that shows a div element skewed 20 degrees along the X-axis using the CSS skewX() transform function. Include both a normal div and the skewed div for comparison.
Output: complete HTML page

The CSS skewY() Function

skewY() does the same on the other axis: the element leans along the Y-axis by the angle you pass.

Example

On the Y-axis this time, the <div> below leans by 20 degrees.

Prompt
Create a page that shows a div element skewed 20 degrees along the Y-axis using the CSS skewY() transform function. Include both a normal div and the skewed div for comparison.
Output: complete HTML page

The CSS skew() Function

To skew along both axes in one call, pass skew() an angle for X and an angle for Y.

Leave out the second parameter and it counts as zero, so the element leans on the X-axis alone.

Skew along both axes

Two angles are given to the <div> here: 20 degrees for the X-axis and 10 degrees for the Y-axis.

Prompt
Create a page that shows a div element skewed 20 degrees along the X-axis and 10 degrees along the Y-axis using the CSS skew() transform function. Include both a normal div and the skewed div for comparison.
Output: complete HTML page

Skew with one parameter

With a single parameter of 20 degrees, the <div> leans only along the X-axis.

Prompt
Create a page that shows a div element skewed 20 degrees along the X-axis using the CSS skew() function with only one parameter. Include both a normal div and the skewed div for comparison.
Output: complete HTML page

The CSS matrix() Function

matrix() merges every 2D transform function into one call.

matrix(scaleX(), skewY(), skewX(), scaleY(), translateX(), translateY()) shows its six parameters in order.

A single declaration can therefore rotate, scale, move (translate), and skew an element.

Example

Prompt
Create a page that shows a div element transformed using the CSS matrix() function with values matrix(1, -0.3, 0, 1, 0, 0). Include both a normal div and the transformed div for comparison.
Output: complete HTML page