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.

3241 questions
8113
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: test ...produces a document with a red background across all browsers and platforms. On the other hand,…
user456584
  • 79,881
  • 11
  • 69
  • 105
477
votes
7 answers

Is background-color:none valid CSS?

Can anyone tell me if the following CSS is valid? .class { background-color:none; }
NarfkX
  • 4,925
  • 2
  • 12
  • 7
359
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
  • 112,774
  • 126
  • 328
  • 461
306
votes
4 answers

How to set text color to a text view programmatically

How can I set Text Color of a text view to #bdbdbd programatically?
Noby
  • 5,992
  • 9
  • 37
  • 63
299
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,102
  • 32
  • 88
  • 126
239
votes
15 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
  • 7,909
  • 18
  • 63
  • 84
235
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,141
  • 6
  • 24
  • 38
201
votes
6 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,475
  • 13
  • 44
  • 80
190
votes
7 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
  • 15,788
  • 40
  • 119
  • 171
189
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,162
  • 33
  • 60
  • 66
185
votes
12 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
  • 9,616
  • 17
  • 45
  • 61
181
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
  • 5,515
  • 15
  • 60
  • 102
159
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,701
  • 2
  • 11
  • 7
157
votes
18 answers

Best way to change the background color for an NSView

I'm looking for the best way to change the backgroundColor of an NSView. I'd also like to be able to set the appropriate alpha mask for the NSView. Something like: myView.backgroundColor = [NSColor colorWithCalibratedRed:0.227f …
BadPirate
  • 24,683
  • 10
  • 85
  • 118
154
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,362
  • 3
  • 11
  • 19
1
2 3
99 100