Lesson: HTML5 and CSS
Give a Background Color to a Div Element
You can set an element's background color with the background-color
property.
For example, if you wanted an element's background color to be green
, you'd put this within your style
element:
.green-background {
background-color: green;
}
Create a class called silver-background
with the background-color
of silver. Assign this class to your div
element.
The content on this page is licensed under Attribution-ShareAlike 4.0 International. Original authors: freeCodeCamp, the content was modified.