CSS background-color Property
CSS background-color Property
CSS background-color
property sets the background color of an element.
Example
Syntax
Using CSS
Using Javascript
Animatable
Yes, background-color property is animatable. CSS Animatable Properties Reference.
Default Value
Default value for CSS background-color property is white.
Property Value
The following table provides a list of values for CSS background-color
property.
Value | Explanation |
---|---|
text | Specifies the name of the background-color in text. For example, black. |
hex | Specifies the name of the background-color in Hexadecimal value. For example, #000000 |
rgb | Specifies the name of the background-color in rgb(red, green, blue) value. For example, rgb(0, 0, 0) |
rgba | Specifies the name of the background-color in rgba(red, green, blue, opacity) value. For example, rgb(0, 0, 0, 0.5) |
hsl | Specifies the name of the background-color in hsl(hue, saturation, lightness) value. For example, hsl(0, 0%, 0%) |
hsla | Specifies the name of the background-color in hsla(hue, saturation, lightness, opacity) value. For example, hsl(0, 0%, 0%, 0.5) |
Using Hexadecimal Value
In the following example, we will use hexadecimal value to set background color.
Example
Using rgb Value
In the following example, we will use rgb value to set background color.
Example
Using rgba Value
In the following example, we will use rgba value to set background color.
Example
Using hsl Value
In the following example, we will use hsl value to set background color.
Example
Using hsla Value
In the following example, we will use hsla value to set background color.
Example
Using JavaScript
In the following example, we will demonstrate how to change the CSS background-color
property of an element using JavaScript.
Example
Reminder
Hi Developers, we almost covered 98.7% of CSS Tutorials with examples for quick and easy learning.
We are working to cover every Single Concept in CSS.
Please do google search for:
Join Our Channel
Join our telegram channel to get an instant update on depreciation and new features on HTML, CSS, JavaScript, jQuery, Node.js, PHP and Python.
This channel is primarily useful for Full Stack Web Developer.