Home
HTML
HTML Background Image
Example 9: HTML Background Image
Run ❯❯
<!DOCTYPE html> <html> <head> <title>background-size: contain</title> <style> body { background-image: url('othertrees.jpg'); background-repeat: no-repeat; background-attachment: fixed; background-size: contain; } </style> </head> <body> <h1>background-size: contain</h1> <p style="color:red;">Here the CSS background-size property is set to 'contain'.<br> The browser scales width and height of the background image such that it fits in the element. Due to this you may notice blank space near the image.</p> </body> </html>