Questions
20 of 30
1What is the purpose of the transform property in CSS?
2What are the different types of CSS transformations?
3What does transform: translate() do?
4What is the difference between translateX() and translateY()?
5How does rotate() work in CSS?
6What is the unit used in rotation?
7What is the difference between scale() and scaleX(), scaleY()?
8What happens when you use negative values in scale()?
9What does the skew() function do?
10Can you combine multiple transform functions together? How? What is the use of the transform-origin property?
11What is the default transform-origin value?
12How does changing transform-origin affect rotation or scaling?
13What is the difference between translate() and using position or margin for movement?
14What is the difference between 2D and 3D transformations?
15What is the difference between 2D and 3D transformations?
16How do you apply a 3D rotation using CSS?
17How do you apply a 3D rotation using CSS?
18What are perspective and perspective-origin in 3D transforms? What is the purpose of transform-style: preserve-3d?
19What is the use of matrix() in CSS transforms?
20What’s the difference between matrix() and matrix3d()?
21How can you center an element using transform and translate()?
22What is the transition property in CSS used for?
23What are the four main components of a transition?
24What does transition-duration specify?
25What are the common timing function values (e.g., ease, linear, ease-in)?
26What is the shorthand syntax for transition?
27Can multiple CSS properties be transitioned simultaneously? How does transition differ from animation in CSS?
28Can you apply a transition to an element’s pseudo-class (like :hover)?
29Can transitions be triggered by JavaScript?
30What happens if transition-duration is set to 0s?
20 / 30

What’s the difference between matrix() and matrix3d()?

Comparing matrix() and matrix3d() in CSS Transforms

Both matrix() and matrix3d() are CSS transform functions used to apply complex transformations by defining mathematical transformation matrices. The main difference is that matrix() handles 2D transformations, while matrix3d() handles 3D transformations that include depth (the Z-axis).

The matrix() function allows you to combine multiple 2D transforms such as scaling, rotating, skewing, and translating in a single statement using six parameters.

Syntax (2D)
Parameters
  1. 1

    a, d — control scaling on the X and Y axes.

  2. 2

    b, c — control skewing.

  3. 3

    tx, ty — control translation along the X and Y axes.

Example

The matrix3d() function extends this concept to 3D space, allowing rotations, translations, scaling, and perspective effects along all three axes (X, Y, and Z). It uses 16 parameters that define a 4×4 matrix.

Syntax (3D)

Although writing a matrix3d() by hand is rare (since it’s complex), browsers use it internally when multiple 3D transformations like rotateX(), rotateY(), or translateZ() are combined.

Example: Using matrix3d() for 3D Rotation
matrix() vs matrix3d()
  1. 1

    matrix() — works only in 2D space (X and Y axes).

  2. 2

    matrix3d() — extends transformations into 3D space, adding depth via the Z-axis.

  3. 3

    matrix3d() uses 16 values compared to 6 in matrix().

  4. 4

    matrix3d() supports perspective and 3D rotations like rotateX() and rotateY().

Best Practices
  1. 1

    Use matrix() for 2D animations and transformations (simple UI effects).

  2. 2

    Use matrix3d() when working with 3D rotations, perspective, or depth.

  3. 3

    Avoid writing raw matrices manually — instead, combine CSS transform functions and let the browser compute the equivalent matrix.

In summary, matrix() is for 2D transformations, while matrix3d() enables full 3D manipulation with perspective — both offering advanced control for transitions and animations.