Is there a color code for transparent in HTML?
Asked Answered
S

10

77

I'm building a new website, and I'm looking for a transparent navigation bar so the background is visible.

Snot answered 12/8, 2013 at 14:11 Comment(2)
Yes, there is for certain browsers (new feature). Please, take a look at https://mcmap.net/q/122733/-css-setting-background-opacity-without-rgbaCheliform
See also: #11184617Tgroup
B
84

There is not a Transparent color code, but there is an Opacity styling. Check out the documentation about it over at developer.mozilla.org

You will probably want to set the color of the element and then apply the opacity to it.

.transparent-style{

    background-color: #ffffff;
    opacity: .4;

}

You can use some online transparancy generatory which will also give you browser specific stylings. e.g. take a look at http://www.css-opacity.pascal-seven.de/

Note though that when you set the transparency of an element, any child element becomes transparent also. So you really need to overlay any other elements.

You may also want to try using an RGBA colour using the Alpha (A) setting to change the opacity. e.g.

.transparent-style{
    background-color: rgba(255, 255, 255, .4);
}

Using RGBA over opacity means that your child elements are not transparent.

Bennett answered 12/8, 2013 at 14:16 Comment(3)
I'm building my website with Tumblr, where do i have to paste the code you've just gave me?Snot
I do not know the Tumblr set up. You need to put this in the stylesheet, and identify the id or class that matches the navigation bar.Bennett
Technically, the "transparent" color keyword is a shortcut for rgba(0,0,0,0), a fully transparent black, vgl. developer.mozilla.org/en-US/docs/Web/CSS/…Aforethought
G
41

When you have a 6 digit color code e.g. #ffffff, replace it with #ffffff00. Just add 2 zeros at the end to make the color transparent.

Here is an article describing the new standard in more depth: https://css-tricks.com/8-digit-hex-codes/

Greek answered 20/2, 2014 at 19:47 Comment(3)
You need to specify which browser/version can use this. ARGB is not in the CSS3 spec (stackoverflow.com/a/12742729) so this is non-standard behavior, and I don't recommend it in any case.Sivia
The recently adopted CSS standard for hex with alpha is #RRGGBBAA so that'd be #ffffff00. It just got added to the standard and adopted by browsers in mid-2017. So it's not really recommended, at least not yet, as it's not currently supported in IE/Edge/Opera.Discourteous
The correct is add in the start #XXFFFFFF when XX: 00 is 0%, 88 50% FF 100%Acea
C
29

All you need is this:

#ffffff00

Here the ffffff is the color and 00 is the transparency

Also, if you want 50% transparent color, then sure you can do... #ffffff80

Where 80 is the hexadecimal equivalent of 50%. Since the scale is 0-255 in RGB Colors, the half would be 255/2 = 128, which when converted to hex becomes 80

And since in transparent we want 0 opacity, we write 00

Charlatanry answered 25/12, 2017 at 20:4 Comment(6)
For 50% you'd actually need to use #FFFFFF7F, since you're dealing with hex values.Cytokinesis
50% is 80 for two digits in hex. css-tricks.com/8-digit-hex-codesMancunian
Hey, this color gives me blue!!!Wilkens
#ffffff00 gives me yellow (#FFFF00) with mpv for subs background.Axinomancy
@Axinomancy make sure there are 6 F's. And not 4. Because #FFFF00 is indeed yellow. For transparent white, go for #FFFFFF7F But it won't work in software like Adobe Photoshop etc.Charlatanry
I've got it in the end. Thanks. gist.github.com/lopspower/…Axinomancy
C
20

#0000ffff - that is the code that you need for transparent. I just did it and it worked.

Corelation answered 24/7, 2014 at 5:37 Comment(0)
L
17

You can specify value to background-color using rgba(), as:

.style{
        background-color: rgba(100, 100, 100, 0.5);
}

0.5 is the transparency value

0.5 is more like semi-transparent, changing the value from 0.5 to 0 gave me true transparency.

Lamrouex answered 12/8, 2013 at 14:33 Comment(0)
C
12

According to MDN there is a transparent keyword, which is short for rgba(0,0,0,0).

{background-color: transparent;}
Callista answered 1/9, 2015 at 18:1 Comment(1)
While this is correct, please explain a bit more about the answer instead of just pasting code.Habile
O
7

If you are looking for android apps, you can use

#00000000 
Olympium answered 14/1, 2020 at 20:20 Comment(1)
Please read the question & tags. It's clearly an HTML, CSS question.Charlatanry
D
4

Yeah I think the best way to transparent the background colour (make opacity only for the background) is using

.style{
        background-color: rgba(100, 100, 100, 0.5);
}

Above statement 0.5 is the opacity value.

It only apply the opacity changes to the background colour (not all elements')

The "opacity" attribute in the CSS will transparent all the elements in the block.

Dracaena answered 7/11, 2015 at 5:34 Comment(0)
D
1

Here, instead of making navigation bar transparent, remove any color attributes from the navigation bar to make the background visible.

Strangely, I came across this thinking that I needed a transparent color, but all I needed is to remove the color attributes.

.some-class{
    background-color: #fafafa; 
}

to

.some-class{
}
Dosser answered 28/9, 2015 at 9:1 Comment(0)
O
0

Yeah! It's #00000000 (or #0000). The first 6 numbers are the color code and the last 2 numbers are the opacity.

.transparent {
  color: #0000;
}
.half-transparent {
  color: #0008;
}
.fully-visible {
  color: #000f;
}
<div class="transparent">I'm John Cena</div>
<div class="half-transparent">I'm almost transparent</div>
<div class="fully-visible">I'm fully visible!</div>
Oscillograph answered 2/6 at 11:56 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.