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.

3509 questions
8506
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
  • 84,369
  • 15
  • 75
  • 107
534
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,515
  • 2
  • 13
  • 7
382
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
  • 116,896
  • 130
  • 334
  • 471
334
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,382
  • 9
  • 39
  • 63
322
votes
17 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,578
  • 33
  • 91
  • 128
276
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
  • 8,737
  • 19
  • 66
  • 89
263
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
  • 6,751
  • 6
  • 25
  • 38
227
votes
17 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,192
  • 3
  • 14
  • 25
223
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,345
  • 15
  • 67
  • 103
219
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
  • 4,960
  • 14
  • 50
  • 88
206
votes
14 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
  • 11,116
  • 17
  • 48
  • 61
201
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,382
  • 41
  • 120
  • 172
190
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,470
  • 33
  • 61
  • 66
172
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,831
  • 2
  • 12
  • 7
165
votes
20 answers

How to change row color in datagridview

I would like to change the color of a particular row in my datagridview. The row should be changed to red when the value of columncell 7 is less than the value in columncell 10. Any suggestions on how to accomplish this?
EB.
  • 2,567
  • 8
  • 33
  • 53
1
2 3
99 100