Jump to content

background-color

From Web Development Wiki

background-color is a CSS property that sets the background color of a element.

Syntax[edit]

background-color = 
  <color>  

Examples[edit]

#text1 {
    background-color: red;
}
#text2 {
    background-color: green;
}
#text3 {
    background-color: #456789;
}
#text4 {
    background-color: #dca976;
}
<p id="text1">This is a example</p>
<p id="text2">This is a example</p>
<p id="text3">This is a example</p>
<p id="text4">This is a example</p>

This is a example

This is a example

This is a example

This is a example

Browser support[edit]

MediaWiki Desktop Mobile
Modern (Grade A)[note 1] Basic (Grade C)[note 2] Chrome IE/Edge Firefox Safari Opera Chrome Firefox Opera Samsung Internet iOS Safari Android WebView
1 4 1 1 3.5 18 4 10.1 1 1 2.1

Notes[edit]

  1. Defined as browser versions that are less than three years old as well as Safari 11.1+. This includes Chromium browers based on version 100+ (Chrome 100+, Edge 100+, Opera 86+, Samsung Internet 19+) and Firefox 99+.
  2. Defined as Chromium browsers based on version 49+ (Chrome 49+, Edge 79+, Opera 36+, Samsung Internet 5+), Firefox 49+ and Safari 10+