How to change background color in CSS?The background-color property in CSS is used to set the background color of an element. It applies solid colors as the element's background. The background of an element covers the total size, including the padding and border, but excluding margin. It can be applied to all HTML elements. SyntaxThe color_name value of this property defines the value of background color or specifies the color codes. It can be given by using the color name, rgb() value, or the hexadecimal value. The transparent value of this property is the default value, which specifies the transparent background color. ExampleIn this example, we are defining the value of the background-color property by using the color name, hexadecimal value, rgb() value, and the hsl() value. There are four div elements on which we apply the background-color property. Test it NowOutput
Next TopicHow to change the font size in CSS
|