Easy Tutorial
❮ Prop Datetime Required Prop Loc Pathname ❯

backgroundSize Property

Style Object

Example

Specify the size of the background image:


Definition and Usage

The backgroundSize property sets or returns the size of the background image.


Browser Support

IE9+, Firefox, Opera, Chrome, and Safari support the backgroundSize property.


Syntax

Return the backgroundSize property:

Set the backgroundSize property:

Property Values

Value Description
auto Default value. The background image contains its width and height.
length Sets the width and height of the background image. The first value sets the width, the second value sets the height. If only one value is given, the second is set to "auto".
percentage Sets the width and height of the background image in percent of the parent element. The first value sets the width, the second value sets the height. If only one value is given, the second is set to "auto".
cover Maintains the aspect ratio of the image and scales the image to the smallest size that covers the entire background area. Some parts of the background image may not be displayed within the background positioning area.
contain Maintains the aspect ratio of the image and scales the image to the largest size that fits within the content area.
initial Sets this property to its default value. See initial
inherit Inherits this property from its parent element. See inherit

Technical Details

Default value: auto
Return value: A string representing the background-size property of the element.
--- ---
CSS version CSS3
--- ---

Related Articles

CSS Reference: background-size Property


Style Object

❮ Prop Datetime Required Prop Loc Pathname ❯