HTML Diff
0 added 0 removed
Original 2026-01-01
Modified 2026-03-09
1 <p>By default, the browser does not resize the background image. However, what if you need to set the background to a different width and height or bind its dimensions to the dimensions of the parent block?</p>
1 <p>By default, the browser does not resize the background image. However, what if you need to set the background to a different width and height or bind its dimensions to the dimensions of the parent block?</p>
2 <p>You can do this using the background-size property. It takes two arguments as a value: the first is the width of the background image, and the second is its height. The second argument is optional. If the height is not specified, then it is determined automatically depending on the width and original proportions. By default, both arguments are auto.</p>
2 <p>You can do this using the background-size property. It takes two arguments as a value: the first is the width of the background image, and the second is its height. The second argument is optional. If the height is not specified, then it is determined automatically depending on the width and original proportions. By default, both arguments are auto.</p>
3 <p>Example:</p>
3 <p>Example:</p>
4 background-size: auto auto; /* Original image width and height */ background-size: 100px; /* Width of 100px, proportional height */ background-size: 100px 200px; /* Width of 100px, height of 200px */<p>Let’s see how this property works in practice.</p>
4 background-size: auto auto; /* Original image width and height */ background-size: 100px; /* Width of 100px, proportional height */ background-size: 100px 200px; /* Width of 100px, height of 200px */<p>Let’s see how this property works in practice.</p>