CSS background-size Property


In CSS, the background-size property is used to specify the size of the background images.

Syntax

Example

Preview

Property Values

Value Description
auto The default value. The background picture is seen in its entirety.
length Sets the background image's width and height. The first parameter determines the width, while the second determines the height. If just one value is specified, the second value is set to "auto." Learn more about length units.
percentage Sets the background image's width and height as a percentage of the parent element. The first parameter determines the width, while the second determines the height. If just one value is specified, the second value is set to "auto."
cover Resize the background picture to fill the full container, even if it means stretching the image or trimming a little portion of one of the sides.
contain Resize the background picture so that it is completely visible.
initial Set this property's value to the default.
inherit This attribute is inherited from its parent element.

Supported Browsers

Element Chrome Firefox Safari Edge / IE Opera
background-size 4.0 
1.0 -webkit-
4.0 
3.6 -moz-
4.1 
3.0 -webkit-
9.0 10.5 
10.0 -o-

More Example