ARGB Hex color not working in css html
Asked Answered
O

3

23

Why is this ARGB hex not working?

<td style="background-color: #FFFF9980">
Oldham answered 30/5, 2012 at 11:28 Comment(2)
first it's RGBA not ARGB & in HEX there are 6 digits but in your question there are 8Metacarpal
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.Injure
S
50

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)).

Samhita answered 30/5, 2012 at 11:30 Comment(4)
@Metacarpal I did read the question. And before you edited it it said ARGB.Samhita
@Metacarpal 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.Samhita
i just changed ARGB into RGBA. I am not changing the questionMetacarpal
@Metacarpal 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?.Samhita
A
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.

Ambassadress answered 5/10, 2012 at 8:50 Comment(2)
CSS Color model 4, editor's draft dated 07oct2013, defines an 8-digit hex notation for RGBA: #RRGGBBAA. See dev.w3.org/csswg/css-color/#hex-notation .Recap
@EdBurnette To be fair this answer was given a year before that draft.Samhita
S
-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>
Sallyanne answered 11/7, 2019 at 11:12 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.