[Go to site: main page, start]

CSS Background Code

You can use CSS to add background effects to any HTML element.

The following CSS background codes demonstrate the various CSS properties you can use to style the background of any HTML element.

CSS Background Color

To set the background color of an element, use the background-color property.

View Output Full Screen Preview

CSS Background Image

To add a background image to an element, use the background-image property.

View Output Full Screen Preview

CSS Background Repeat

Determines whether the background image repeats (tiles) or not. For info on the possible values, see background-repeat.

View Output Full Screen Preview

CSS Background Position

Determines the position of the background image. For more information, see background-position.

View Output Full Screen Preview

CSS Background Attachment

Determines whether or not the background image scrolls with the outer container. For more information, see background-attachment.

View Output Full Screen Preview

Shorthand Code

You can use the background property to set all the background properties at once. For more information, see background.

View Output Full Screen Preview