×

Save Your Code

If you click the save button, your code will be saved, and you get an URL you can share with others.

By clicking the "Save" button you agree to our terms and conditions.

Report Error

×

Save to Google Drive

If you have a Google account, you can save this code to your Google Drive.

Google will ask you to confirm Google Drive access.

×

Open from Google Drive

If you have saved a file to Google Drive, you can open it here:

Result Size: 625 x 571
x
 
<!DOCTYPE html>
<html>
<head>
<style>
#example1 {
  border: 2px solid black;
  padding: 25px;
  background: url(mountain.jpg);
  background-repeat: no-repeat;
  background-size: auto;
}
#example2 {
  border: 2px solid black;
  padding: 25px;
  background: url(mountain.jpg);
  background-repeat: no-repeat;
  background-size: 300px 100px;
}
</style>
</head>
<body>
<h2>background-size: auto (default):</h2>
<div id="example1">
  <h2>Hello World</h2>
  <p>The background image is displayed in its original size.</p>
</div>
<h2>background-size: 300px 100px:</h2>
<div id="example2">
  <h2>Hello World</h2>
  <p>Here, the background image is set to 300px wide and 100px high.</p>
</div>
<p><strong>Note:</strong> The background-size property is not supported in Internet Explorer 8 and earlier versions.</p>
</body>
<!-- Mirrored from www.w3schools.com/cssref/tryit.asp?filename=trycss3_background-size by HTTrack Website Copier/3.x [XR&CO'2014], Mon, 27 Jan 2020 03:00:12 GMT -->
</html>
×

Report a Problem: