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.

3407 questions
8350
votes
10 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, the following code produces a page with a red background across all browsers and platforms: test On the…
user456584
  • 82,549
  • 12
  • 72
  • 107
517
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,345
  • 2
  • 13
  • 7
376
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
  • 115,408
  • 128
  • 331
  • 467
325
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,252
  • 9
  • 38
  • 63
314
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,410
  • 33
  • 90
  • 127
259
votes
18 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,327
  • 18
  • 65
  • 85
249
votes
5 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,501
  • 6
  • 25
  • 38
210
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,725
  • 14
  • 47
  • 84
207
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,065
  • 15
  • 63
  • 102
200
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
  • 10,406
  • 17
  • 47
  • 61
197
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,176
  • 40
  • 119
  • 172
196
votes
14 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
  • 2,872
  • 3
  • 12
  • 22
190
votes
17 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,350
  • 33
  • 61
  • 66
166
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,771
  • 2
  • 12
  • 7
160
votes
19 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,517
  • 8
  • 33
  • 50
1
2 3
99 100