Style backgroundColor property
- 上一页 backgroundAttachment
- 下一页 backgroundImage
- 返回上一层 Object Style HTML DOM
Definition and usage
backgroundColor
Set or return the background color of the element.
See also:
HTML style:background property
CSS tutorial:CSS ɗanin Background
CSS reference manual:background-color property
Instance
Example 1
Set background color for the document:
document.body.style.backgroundColor = "red";
Example 2
Set the background color of the specific <div> element:
document.getElementById("myDiv").style.backgroundColor = "lightblue";
Example 3
Return the background color of the specific <div> element:
alert(document.getElementById("myDiv").style.backgroundColor);
Example 4
Return the background color of the document:
alert(document.body.style.backgroundColor);
Syntax
Return backgroundColor property:
object.style.backgroundColor
Set backgroundColor property:
object.style.backgroundColor = "color|transparent|initial|inherit"
Attribute value
Value | Description |
---|---|
color |
define background color. Please check CSS color values, to get the complete list of possible color values. |
transparent | Default. Background color is transparent (the underlying content will show through). |
initial | Set kimiya ta dake kama gurawar kama. Kaya ka initial. |
inherit | Yinwarin kimiya ta dake gurawar kama. Kaya ka inherit. |
Technical details
Default value: | transparent |
---|---|
Return value: | kalimata, wato background color. |
CSS versiyon: | CSS1 |
tukiya suka tukiya
backgroundColor
ni kama CSS1 (1996) kimiya.
kukun dukiya suka tukiya
Chrome | Edge | Firefox | Safari | Opera | IE |
---|---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera | IE |
tukiya | tukiya | tukiya | tukiya | tukiya | tukiya |
- 上一页 backgroundAttachment
- 下一页 backgroundImage
- 返回上一层 Object Style HTML DOM