Questions tagged [background-color]

"background-color" is a CSS property used to define the background color of an element. Tag these questions with "css" also.

The background-color CSS property sets the background color of an element.

The background of an element is the total size of the element, including padding and border (but not the margin).

The possible values are:

  • transparent (this is the default value)
  • inherit (to specify the same value than the element's parent)
  • a valid CSS color value (#00FF00, red, rgb(0, 255, 0), etc.)

More information can be found on W3schools, the W3C website, and MDN.

3655 questions
8678
votes
9 answers

Why does HTML think “chucknorris” is a color?

Why do certain random strings produce colors when entered as background colors in HTML? For example, bgcolor="chucknorris" produces a red background: test Conversely, bgcolor="chucknorr" produces a yellow…
user456584
  • 86,427
  • 15
  • 75
  • 107
569
votes
7 answers

Is background-color:none valid CSS?

Can anyone tell me if the following CSS is valid? .class { background-color:none; }
NarfkX
  • 5,865
  • 2
  • 14
  • 7
390
votes
18 answers

Animate change of view background color on Android

How do you animate the change of background color of a view on Android? For example: I have a view with a red background color. The background color of the view changes to blue. How can I do a smooth transition between colors? If this can't be…
hpique
  • 119,096
  • 131
  • 338
  • 476
348
votes
4 answers

How to set text color of a TextView programmatically?

How can I set the text color of a TextView to #bdbdbd programatically?
Noby
  • 6,562
  • 9
  • 40
  • 63
328
votes
16 answers

What is the difference between background and background-color

What's the difference between specifying a background color using background and background-color? Snippet #1 body { background-color: blue; } Snippet #2 body { background: blue; }
stanigator
  • 10,768
  • 34
  • 94
  • 129
296
votes
19 answers

Semi-transparent color layer over background-image?

I have a DIV and I would like to put a pattern as background. This pattern is gray. So to make it a little more nice, I would like to put a light transparent color "layer" over. Below is what I tried but which did not work. Is there a way to put the…
Marc
  • 9,217
  • 21
  • 67
  • 90
282
votes
20 answers

SwiftUI - How do I change the background color of a View?

I'm beginning to try out SwiftUI and I'm surprised that it doesn't seem to be straightforward to change the background color of a View. How do you do this using SwiftUI?
jeremyabannister
  • 3,796
  • 3
  • 16
  • 25
270
votes
6 answers

Sass - Converting Hex to RGBa for background opacity

I have the following Sass mixin, which is a half complete modification of an RGBa example: @mixin background-opacity($color, $opacity: .3) { background: rgb(200, 54, 54); /* The Fallback */ background: rgba(200, 54, 54, $opacity); } I have…
Rick Donohoe
  • 7,081
  • 6
  • 26
  • 38
245
votes
14 answers

CSS: Set a background color which is 50% of the width of the window

Trying to achieve a background on a page that is "split in two"; two colors on opposite sides (seemingly done by setting a default background-color on the body tag, then applying another onto a div that stretches the entire width of the window). I…
Staffan Estberg
  • 6,795
  • 16
  • 71
  • 107
224
votes
7 answers

How to make div background color transparent in CSS

I'm not using CSS3. So I can't use opacity or filter attributes. Without using these attributes how can I make the background-color transparent of a div? It should be kind of the text box example in this link. Here the text box background color is…
Mistu4u
  • 5,132
  • 15
  • 53
  • 91
219
votes
13 answers

CSS: background image on background color

I have panel which I colored blue if this panel is being selected (clicked on it). Additionally, I add a small sign (.png image) to that panel, which indicates that the selected panel has been already selected before. So if the user sees for example…
mkn
  • 12,024
  • 17
  • 49
  • 62
205
votes
8 answers

Set background color of WPF Textbox in C# code

How can I change the background and foreground colors of a WPF Textbox programmatically in C#?
Sauron
  • 16,668
  • 41
  • 122
  • 174
192
votes
10 answers

Why can't I use background image and color together?

What I am trying to do is to show both background-color and background-image, so that half of my div will cover the right shadow background image, and the other left part will cover the background color. But when I use background-image, the color…
Yasir
  • 3,817
  • 10
  • 35
  • 41
191
votes
18 answers

How to customize the background color of a UITableViewCell?

I would like to customize the background (and maybe the border too) of all of the UITableViewCells within my UITableView. So far I have not been able to customize this stuff, so I have a bunch of white background cells which is the default. Is there…
jpm
  • 16,622
  • 34
  • 63
  • 66
179
votes
8 answers

Set Background color programmatically

I try to set background color programmatically but when I set every one of my colors, the background being black but with any color background being white like the application theme. View someView = findViewById(R.id.screen); View root =…
user3274646
  • 1,901
  • 2
  • 13
  • 7
1
2 3
99 100