You are on page 1of 1

4/11/2019 Tryit Editor v3.

     Run »

<!DOCTYPE html>
<html> background-size: auto (default):
<head>
<style>
#example1 {
border: 2px solid black;
padding: 25px; Hello World
background: url(mountain.jpg);
background-repeat: no-repeat;
The background image is displayed in its
background-size: auto;
original size.
}

#example2 {
border: 2px solid black;
padding: 25px;
background: url(mountain.jpg);
background-size: 300px 100px:
background-repeat: no-repeat;
background-size: 300px 100px;
}
</style>
</head>
Hello World
<body>
Here, the background image is set to 300px
<h2>background-size: auto (default): wide and 100px heigh.
</h2>
<div id="example1">
<h2>Hello World</h2>
<p>The background image is displayed Note: The background-size property is not
in its original size.</p> supported in Internet Explorer 8 and earlier versions.
</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 heigh.</p>
</div>

<p><strong>Note:</strong> The
background-size property is not
supported in Internet Explorer 8 and
earlier versions.</p>

</body>

https://www.w3schools.com/cssref/tryit.asp?filename=trycss3_background-size 1/1

You might also like