Open In App

CSS Value | Angle

The angle on CSS represents a certain angle value that can be expressed in degrees, gradians, radians, or turns. Angle value can be used for rotations, transformations or gradients, etc.

Syntax: The angle consists of a number followed by one of the allowed units.



property: number unit;

Allowed units:

Example 1: using the deg unit to rotate an element by 90 degrees.






<!DOCTYPE html>
<html>
<meta charset="utf-8">
<head>
  <title>CSS | value angle</title>
</head>
<style>
    div{
      transform: rotate(90deg);
      }
</style>
<body>
    <h1 style="text-align: center; color: green;">GeeksforGeeks</h1>
    <div style="width: 100px; height: 200px;
         margin-left: 46vw; background: green;">
    </div>
</body>
</html>

Output:

Example 2: using the rad unit to rotate an element.




<!DOCTYPE html>
<html>
<meta charset="utf-8">
<head>
  <title>CSS | value angle</title>
</head>
<style>
    div{
      transform: rotate(2rad);
    }
</style>
<body>
    <h1 style="text-align: center; color: green;">GeeksforGeeks</h1>
    <div style="width: 100px; height: 200px;
         margin-left: 46vw; background: green;">
    </div>
</body>
</html>

Output:

Example 3: using the grad unit to rotate an element.




<!DOCTYPE html>
<html>
<meta charset="utf-8">
<head>
  <title>CSS | value angle</title>
</head>
<style>
    div{
      transform: rotate(10grad);
    }
</style>
<body>
    <h1 style="text-align: center; color: green;">
        GeeksforGeeks
    </h1>
    <div style="width: 100px; height: 200px;
         margin-left: 46vw; background: green;">
    </div>
</body>
</html>

Output:

Example 4: using the turn unit to rotate an element.




<!DOCTYPE html>
<html>
<meta charset="utf-8">
<head>
  <title>CSS | value angle</title>
</head>
<style>
    div{
      transform: rotate(1.25turn);
    }
</style>
<body>
    <h1 style="text-align: center; color: green;">
           GeeksforGeeks</h1>
    <div style="width: 100px; height: 200px;
         margin-left: 46vw; background: green;">
    </div>
</body>
</html>

Output:

Supported Browsers:


Article Tags :