
The ability to set the background color on an HTML page has been around almost since the first Web browsers. However, with CSS you can define the background color, not only for the entire page, but also for individual elements using the background- color property. Unlike the color property, though, background colors are applied only to the element, and are not directly inherited by its children. That said, by the very fact they are within the parent, they will be set against that background. To define the background color of an element: 1. Add the background color property to your declaration list. Start your declaration by typing background-color, followed by a colon (:). background-color: 2. Specify the color value. Type a value for the background color. This value can be the name of the color or an RGB value. rgb(102,0,0); Alternatively, you could type transparent, which would allow the parent element’s background color to show through, or current color
Background Color Classes | |
---|---|
Class | Defines |
w3-red | Background color red |
w3-pink | Background color pink |
w3-purple | Background color purple |
w3-deep-purple | Background color deep purple |
w3-indigo | Background color indigo |
w3-blue | Background color blue |
w3-light-blue | Background color light blue |
w3-cyan | Background color cyan |
w3-aqua | Background color aqua |
w3-teal | Background color teal |
w3-green | Background color green |
w3-light-green | Background color light green |
w3-lime | Background color lime |
w3-sand | Background color sand |
w3-khaki | Background color khaki |
w3-yellow | Background color yellow |
w3-amber | Background color amber |
w3-orange | Background color orange |
w3-deep-orange | Background color deep orange |
w3-blue-grey | Background color blue grey |
w3-brown | Background color brown |
w3-light-grey | Background color light grey |
w3-grey | Background color grey |
w3-dark-grey | Background color dark grey |
w3-black | Background color black |
w3-pale-red | Background color pale red |
w3-pale-yellow | Background color pale yellow |
w3-pale-green | Background color pale green |
w3-pale-blue | Background color pale blue |
w3-transparent | Transparent background-color |