Home
HTML
HTML Background Image
Example 7: HTML Background Image
Run ❯❯
<!DOCTYPE html> <html> <head> <title>Background Image Stretch Example</title> <style> body { background-image: url('trees.jpg'); background-repeat: no-repeat; background-attachment: fixed; background-size: 100% 100%; } </style> </head> <body> <h1>Background Image Stretch Example</h1> <p style="color:red;">We have set width and height of the background image to 100% in CSS background-size property. This stretches the image to fill the element.</p> </body> </html>