/    Sign up×
Reference /Pin to ProfileBookmark

The background property is shorthand for background-color, background-image, background-position, background-size, background-repeat, background-origin, background-clip, and background-attachment.

Syntax

Any of the above values are allowed to be omitted.

div.ex {
  background: #0000ff url('example-image.jpg') no-repeat fixed right center;
}

Values

background-color
Sets the color of the background.

background-image
Sets an image or multiple images as the background of an element.

background-position
Specifies the position at which a background image starts.

background-size
Specifies the size of a background image.

background-repeat
Sets how and if a background image will repeat itself.

background-origin
Designates the origin position of a background image.

background-clip
Sets how far the background should extend within an element.

background-attachment

Ensures the background-image will or will not scroll with the page.

initial
Sets the property to its default value.

inherit
Inherits this property’s value from its parent item.

Browser Compatibilty

Demos

User-submitted codepen.io examples of background

@marccurtis321

See the Pen on CodePen.

Want to Contribute?

Submit a codepen.io link that demonstrates background:

to submit a demo.
CSS
×

Success!

Help @reference spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 4.13,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...