Introduction
Background repeat controls how a background image repeats across an element. It helps you fill space or create patterns.
Jump into concepts and practice - no test required
Background repeat controls how a background image repeats across an element. It helps you fill space or create patterns.
background-repeat: repeat | repeat-x | repeat-y | no-repeat | space | round;background-repeat: repeat;background-repeat: no-repeat;background-repeat: repeat-x;background-repeat: repeat-y;This example shows a box with a small square background image repeated only horizontally across the box. The background color is light blue to highlight the area.
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1" /> <title>Background Repeat Example</title> <style> .box { width: 15rem; height: 10rem; border: 2px solid #333; background-image: url('https://via.placeholder.com/50'); background-repeat: repeat-x; background-color: #eef; margin: 2rem auto; } </style> </head> <body> <main> <section> <h1>Background Repeat: repeat-x</h1> <div class="box" aria-label="Box with background image repeated horizontally"></div> <p>The small square image repeats only horizontally inside the box.</p> </section> </main> </body> </html>
Use background-repeat: no-repeat; to show the image only once.
Try changing repeat-x to repeat-y to see vertical repetition.
Background images should have good contrast with background color for visibility.
Background repeat controls how background images fill an area.
You can repeat images horizontally, vertically, both, or not at all.
It helps create patterns or keep backgrounds clean and simple.
background-repeat: no-repeat; do to a background image?no-repeatno-repeat means the background image will not be repeated at all.repeat-x or repeat-y repeat the image horizontally or vertically, but no-repeat shows it once.no-repeat means no repeating [OK]repeat-x repeats the background image horizontally, repeat-y vertically, no-repeat no repetition, and repeat repeats both ways.repeat-x is correct.div {
background-image: url('pattern.png');
background-repeat: repeat-y;
width: 200px;
height: 400px;
}background-repeat: repeat-y;section {
background-image: url('tile.png');
background-repeat: repeat-x;
}background-repeat valuerepeat-x repeats the image only horizontally, not vertically.repeat should be used instead.repeat-x repeats only horizontally, not vertically. -> Option Abackground-repeat: repeat-y; and adjusting the container height to exactly 3 times the image height, the image will repeat vertically 3 times and then stop.background-repeat: repeat-y; and set the container height to 3 times the image height. -> Option B