CSS | right Property
The css right property mainly affects the horizontal position of element as well as css property has no effect on non-positioned elements.
Syntax:
right: auto|length|initial|inherit;
Syntax:
right:auto;
Example-1:
<!Doctype html> <html> <head> <style> div.geek { position: relative; width: 300px; height: 200px; border: 3px solid green; } div.geeks { position: absolute; <!-- "auto" right property--> right: auto; width: 100px; height: 120px; border: 3px solid green; } </style> </head> <body> <h1>CSS right Property</h1> <div class="geek"> Geek For Geeks(here position of element is relative) <div class="geeks"> Geek For Geeks (here position of element is absolute and element) </div></div> </body> </html> |
chevron_right
filter_none
Output:

Syntax:
right:length;
Example-2:
<!Doctype html> <html> <head> <style> div.geek { position: relative; width: 300px; height: 200px; border: 3px solid green; } div.geeks { position: absolute; <!-- "length" right property> right: 0px; width: 100px; height: 120px; border: 3px solid green; } </style> </head> <body> <h1>CSS right Property</h1> <div class="geek"> Geek For Geeks(here position of element is relative) <div class="geeks"> Geek For Geeks (here position of element is absolute and element) </div> </div> </body> </html> |
chevron_right
filter_none
Output:

Syntax:
right:initial;
Example-3:
<!Doctype html> <html> <head> <style> div.geek { position: relative; width: 300px; height: 200px; border: 3px solid green; } div.geeks { position: absolute; <!--"initial" right property--> right: initial; width: 100px; height: 120px; border: 3px solid green; } </style> </head> <body> <h1>CSS right Property</h1> <div class="geek"> Geek For Geeks(here position of element is relative) <div class="geeks"> Geek For Geeks (here position of element is absolute and element) </div> </div> </body> </html> |
chevron_right
filter_none
Output:

Syntax:
right:inherit;
Example-4:
<!Doctype html> <html> <head> <style> div.geek { position: relative; width: 300px; height: 200px; border: 3px solid green; } div.geeks { position: absolute; <!--"inherit" right property> right: inherit; width: 100px; height: 120px; border: 3px solid green; } </style> </head> <body> <h1>CSS right Property</h1> <div class="geek"> Geek For Geeks(here position of element is relative) <div class="geeks"> Geek For Geeks (here position of element is absolute and element) </div> </div> </body> </html> |
chevron_right
filter_none
Output:

Supported Browsers:
Recommended Posts:
- CSS | transition-property Property
- CSS | top Property
- CSS | all Property
- CSS | bottom Property
- CSS | max-width Property
- CSS | column-gap Property
- CSS | animation-name Property
- CSS | height Property
- CSS | left Property
- CSS | perspective Property
- CSS | Display property
- CSS | transition Property
- CSS | grid Property
- CSS | border-top Property
- CSS | box-sizing Property
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



