CSS Backgrounds | css background
TheCSSbackgroundpropertiesareusedtoaddbackgroundeffectsforelements.Inthesechapters,youwilllearnaboutthefollowingCSSbackgroundproperties:background-colorbackground-imagebackground-repeatbackground-attachmentbackground-positionbackground(shorthandproperty)CSSbackground-colorThebackground-colorpropertyspecifiesthebackgroundcolorofanelement.ExampleThebackgroundcolorofapageissetlikethis:body{ background-color:lightblue;}TryitYourself»[1]WithCSS,acolorismostoftenspecifiedby:avalidcolorname-like"r...
The CSS background properties are used to add background effects for elements.
In these chapters, you will learn about the following CSS background properties:
background-color background-image background-repeat background-attachment background-position background (shorthand property) CSS background-colorThe background-color property specifies the background color of an element.
ExampleThe background color of a page is set like this:
body { background-color: lightblue;}
Try it Yourself »[1]With CSS, a color is most often specified by:
a valid color name - like "red" a HEX value - like "#ff0000" an RGB value - like "rgb(255,0,0)"Look at CSS Color Values[2] for a complete list of possible color values.
Other ElementsYou can set the background color for any HTML elements:
ExampleHere, the <h1>, <p>, and <div> elements will have different background color...