Show Output
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>Example of CSS3 background-size Property</title> <style> .box { width: 250px; height: 150px; background: url("/examples/images/sky.jpg") no-repeat; background-size: contain; border: 6px solid #333; } </style> </head> <body> <div class="box"></div> <p><strong>Note:</strong> The original size of the background image is 500x300 pixels, but using the background-size property we are still able to show the complete image inside the smaller box.</p> </body> </html>