22

Why is this ARGB hex not working?

<td style="background-color: #FFFF9980">
mikus
  • 3,042
  • 1
  • 30
  • 40
Obsivus
  • 8,231
  • 13
  • 52
  • 97
  • 1
    first it's RGBA not ARGB & in HEX there are 6 digits but in your question there are 8 – sandeep May 30 '12 at 11:32
  • 5
    Hex encoded RGBA/ARGB have 8 digits, I'm not sure what you are trying to say... And ARGB is just as valid of a bit packing for color encoding, though admittedly less common (and not natively supported in HTML/CSS stack). But to the point of the op: do you mean the rgb color `ffff99` with an alpha of `80` or an rgb of `ff9980` and and alpha of `ff`? The bit packing is vital to figuring out what bytes are what, and what color that value represents. You can't just change the encoding and expect to get valid output. – J. Holmes May 30 '12 at 11:39

3 Answers3

49

Use rgba(255,153,128,1.0) instead of your hex value (though if that really is ARGB it's the same as #ff9980 in RGB - if you meant RGBA then you'll need rgba(255,255,153,0.5)).

Gareth
  • 5,693
  • 3
  • 28
  • 37
  • 1
    @sandeep I did read the question. And before you edited it it said `ARGB`. – Gareth May 30 '12 at 11:44
  • 1
    @sandeep The question was asked, I answered a minute later, then you edited the question 3 minutes after that. OP needed a semi-transparent `background-color` as evidenced by the sentence `I really need this color`. I gave him a solution to that problem. – Gareth May 30 '12 at 11:47
  • i just changed ARGB into RGBA. I am not changing the question – sandeep May 30 '12 at 11:49
  • 12
    @sandeep Actually, when you change `ARGB` to `RGBA` you *are* changing the question as they are totally different things. The solution when someone wants to add transparency to their colours is to use `rgba(r,g,b,a)`. When someone asks `Why is this not working?` they very often mean `How can I make this work?`. – Gareth May 30 '12 at 11:53
10

the CSS3 spec says:

Unlike RGB values, there is no hexadecimal notation for an RGBA value.

so you will have to use the rgba(255,153,128,1.0) mentioned above.

  • 1
    CSS Color model 4, editor's draft dated 07oct2013, defines an 8-digit hex notation for RGBA: #RRGGBBAA. See http://dev.w3.org/csswg/css-color/#hex-notation . – Ed Burnette Oct 08 '13 at 19:28
  • 4
    @EdBurnette To be fair this answer was given a year before that draft. – Gareth Oct 27 '13 at 10:59
-1

ARGB Hex color

RGBA color values are an extension of RGB color values with an alpha channel - which specifies the opacity for a color.

An RGBA color value is specified with: rgba(red, green, blue, alpha). The alpha parameter is a number between 0.0 (fully transparent) and 1.0 (fully opaque).

<td style="background-color: rgba(255, 0, 0, 0.2);">

#p1 {background-color:rgba(255,0,0,0.3);}
#p2 {background-color:rgba(0,255,0,0.3);}
#p3 {background-color:rgba(0,0,255,0.3);}
#p4 {background-color:rgba(192,192,192,0.3);}
#p5 {background-color:rgba(255,255,0,0.3);}
#p6 {background-color:rgba(255,0,255,0.3);}
<h1>Define Colors With RGBA Values</h1>

<p id="p1">Red</p>
<p id="p2">Green</p>
<p id="p3">Blue</p>
<p id="p4">Grey</p>
<p id="p5">Yellow</p>
<p id="p6">Cerise</p>