background-size

Back to the index.

This page tests background-size. What is the size of the background image? You can specify it in pixels, percentages, or scale it to fit the box.

auto (default)

The background image is sized normally.

auto

length

The background image’s size is determined by this property (100px 50px in the example).

100px 50px

percentage

The background images’s size is determined by this property (20% 50% in the example). Effectively, this allows you to state how many times the background image is shown, though resizing will occur.

20% 50%

contain

The image is scaled to the largest size that allows it to fit in the box, while retaining proper aspect ratio.

contain

cover

The image is scaled to the largest size that allows it to cover the box completely, while retaining proper aspect ratio.

cover