property

background — CSS reference

Sets the background longhands together. Omitted components reset to initial values, so a later background declaration can erase an earlier image or size. Each image layer may have its own position, repeat and size; only the final layer may specify a color. All core background properties are non-inherited. Use the slash between position and size.

Formal Syntax & Structure

css syntaxcss
<bg-layer># with optional color in final layer (representative)

Working Example

Example Snippetcss
<!doctype html><html lang="en"><meta charset="utf-8"><title>CSS image painting lab</title><style>body {margin:0} .sample {background:#dcebe9;color:#182e32}body{background:white} #a{width:100px;height:80px;background-color:blue}#a{background-image:linear-gradient(red,red);background-size:20px;background:red}</style><body><div id="a" aria-hidden="true"></div><p>Decorative background sample.</p></body></html>
CSS Reference