Background position lets you choose where a background image appears inside an element. It helps you place the image exactly where you want it.
Background position in CSS
background-position: horizontal vertical;Horizontal and vertical can be keywords (like left, center, right, top, bottom) or length values (like 10px, 2rem) or percentages (like 50%).
If you use one value, the second defaults to center.
background-position: center center;background-position: top right;background-position: 20px 30px;
background-position: 75% 50%;
This example shows a box with a small background image placed at the bottom right corner using background-position: bottom right;. The box has a border so you can see the edges clearly.
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1" /> <title>Background Position Example</title> <style> .box { width: 300px; height: 200px; border: 2px solid #333; background-image: url('https://via.placeholder.com/100'); background-repeat: no-repeat; background-position: bottom right; } </style> </head> <body> <main> <section> <h1>Background Position Demo</h1> <div class="box" aria-label="Box with background image positioned at bottom right"></div> <p>The small image is placed at the bottom right corner inside the box.</p> </section> </main> </body> </html>
Using keywords like center, top, left is easier for common positions.
Percentages move the image relative to the element's size, which helps with responsive design.
Remember to set background-repeat: no-repeat; if you want only one image and no tiling.
Background position controls where a background image sits inside an element.
You can use keywords, lengths, or percentages to set horizontal and vertical positions.
It helps you create neat, visually balanced designs by placing images exactly where you want.