background-size

Important

This documentation is preliminary and subject to change.

Sets the size of the background image

Syntax

{ background-size: hSize[, vSize] }

Possible values

hSize, vSize

String that specifies one of the following values:

auto

Default. The aspect ratio of the image is preserved. If either hSize or vSize is assigned a length or percentage value, the image is scaled to fit. If both hSize and vSize are set to auto, the image is scaled to 100% of its original size.

contain

The aspect ratio of the image is preserved and the image is scaled to the largest size that will fit within the background positioning area.

cover

The aspect ratio of the image is preserved and the image is scaled to the smallest size that will completely cover the background positioning area.

length

hSize specifies the width of the image; vSize specifies the height of the image. If only hSize or vSize is specified, the value for the other is set to auto.

percentage

hSize specifies the width of the image; vSize specifies the height of the image. If only hSize or vSize is specified, the value for the other is set to auto. The percentage is calculated relative to the background positioning area.

This property has a default value of auto. It is not inherited.

Standards information

This property is defined in CSS Selectors Level 3 Gg721772.xtlink_newWindow(en-us,Expression.40).png.

Applies to

a, address, b, big, blockquote, body, button, caption, center, cite, code, col, colgroup, custom, dd, defaults, dfn, div, dl, dt, em, fieldset, form, hn, html, i, img, input type=button, input type=checkbox, input type=file, input type=image, input type=password, input type=radio, input type=reset, input type=submit, input type=text, li, ol, p, s, span, sub, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, var, xmp

See also

Concepts

background
background-attachment
background-clip
background-color
background-image
background-origin
background-position
background-repeat

Send feedback about this topic to Microsoft. © 2011 Microsoft Corporation. All rights reserved.