What is CSS rotate()?

Learn via video course
FREE
View all courses
JavaScript Course With Certification: Unlocking the Power of JavaScript
JavaScript Course With Certification: Unlocking the Power of JavaScript
by Mrinal Bhattacharya
1000
4.8
Start Learning
JavaScript Course With Certification: Unlocking the Power of JavaScript
JavaScript Course With Certification: Unlocking the Power of JavaScript
by Mrinal Bhattacharya
1000
4.8
Start Learning
Topics Covered

CSS rotate is an inbuilt function that is used to rotate an element by a certain degree on a 2D plane without changing the shape of the figure.

We can rotate the element in both clockwise and anticlockwise values.

In the CSS rotate function, the input angle can be given as a degree, gradians, radians, or turns and it returns the output in the form of <transform-function> data type.

Syntax

Values

Transform Your Career

Choose from our industry-leading programs designed for career success

NSDC Certified

Modern Software and AI Engineering Program

Master full-stack development with AI integration

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

Modern Data Science and ML with specialisation in AI

Advanced data science techniques with AI specialization

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

Advanced AIML with Specialisation in Agentic AI

Deep dive into AIML with focus on Agentic systems

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

DevOps, Cloud & AI Platform Engineering

Build and manage AI-powered cloud infrastructure

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

AI Engineering Advanced Certification by IIT-Roorkee

Premier AI engineering certification from IIT-Roorkee

3 MonthsDuration
AI-LedCurriculum
Career SupportSupport
Program highlights
Go to Program

none

The none value is used when we don't want to rotate the element.

Example:

Similar to none value, we can use global values too.

<angle>

When we use the angle values we can express them in degrees, gradians, radians, or turns.

Axis Name with <angle> Value

We can write the name of the axis along with the angle value, this will result in the rotation of the element along the defined axis with a defined angle.

Vector Plus Angle Value

We can give a vector value along with the angle for rotation.

Free Courses by top Scaler instructors
Python Course for Beginners With Certification: Mastering the Essentials
Java Course - Mastering the Fundamentals
DBMS Course - Master the Fundamentals and Advanced Concepts
JavaScript Course With Certification: Unlocking the Power of JavaScript
C++ Course: Learn the Essentials
Python and SQL for Data Science Course
Python Course for Beginners With Certification: Mastering the Essentials
Java Course - Mastering the Fundamentals
DBMS Course - Master the Fundamentals and Advanced Concepts
JavaScript Course With Certification: Unlocking the Power of JavaScript
C++ Course: Learn the Essentials
Python and SQL for Data Science Course

Units

When we use the angle values for defining the rotate property, we can express them in degrees, gradians, radians, or turns.

deg

Example:

Scaler Placement Report and Statistics

₹23L
AVG CTC
SCALER PLACEMENT PROOF

Scaler learners achieved 2.5x salary growth with average post-Scaler CTC reaching ₹23L.

11,000+placements
650+companies
Verified data
Hiring Partners:
GoogleGoogleAmazonAmazonMicrosoftMicrosoftFlipkartFlipkartAdobeAdobe1200+ more

grad

Example:

turn

Example:

rad

Example:

Transitions and Animations

When we want to see the 'rotate element' in action or in animation form, we should use the transition property. Transitions change the state of an element and allow us to change property values smoothly, over a given duration. For example, it can be used when a cursor hovers over an element.

Example:

Output:

Before Transition: transitions-and-animations-before-transition

After Transition: transitions-and-animations-after-transition

Turn Learning into Career Growth

1200+Hiring Partners
89%Placement Rate
11,000+Placements
147%Avg Salary Increment
2.5XCareer Growth
₹23 LPAAvg Post-Scaler Salary
1200+Hiring Partners
89%Placement Rate
11,000+Placements
147%Avg Salary Increment
2.5XCareer Growth
₹23 LPAAvg Post-Scaler Salary

When to Use the CSS Transform rotate() Function?

We can use the below syntaxes to use the rotate function.

The major difference between using rotate property vs. using the rotate function with transform is that when we use the rotate property without the transform function we can rotate the element using the Z-axis also. Hence, rotate property is more often used.

Examples

Basic Example

Output:

when-to-use-the-css-transform-rotate-function

Combining Rotation with Another Transformation

We can combine the rotate property with other transform properties also such as skew and scale.

In the below example, we have used scale and rotate together to rotate the element by 45 degrees and scale it by 1.5x along its Y-axis.

Output:

Before Transform: combining-rotation-with-another-transformation-before-transform

After Transform: combining-rotation-with-another-transformation-after-transform

Browser Support

The following browsers fully support the CSS rotate property:

browser-support-css-rotate

Conclusion

  • CSS rotate is an inbuilt function that is used to rotate an element by a certain degree.
  • The input angle can be given as a degree, gradians, radians, or turns along with the axis around which we want to rotate.
  • The CSS rotate property can also be used with other transformation properties like skew and scale.