Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

CSS CSS Basics (2014) Understanding Values and Units Color Values

Corey Hayden
Corey Hayden
11,717 Points

Is using RGBa the only way to specify an alpha channel?

For example, if you decide you want to add some transparency to a color that is already defined using hexadecimal, do you have to convert the value to RGBa?

2 Answers

William Bode
William Bode
7,105 Points

Sorry Mark, but your answer is wrong. Please don't tell people that something cannot be done if you don't know for sure.

Corey: You can simply use "opacity" for your element. for example in this video, instead of h1 { font-size: 5.625em; color: rgba(255, 255, 255, 0.5); }

You can write:

h1 { font-size: 5.625em; color: rgb(255, 255, 255); opacity: 0.5; }

It's not the cleanest solution, but it does work.

It looks like Corey's question is, if an element is defined by #fff, can you add an opacity after it? Or, does the element have to be defined by rgb(255, 255, 255) in order to use an opacity? I was having some trouble understanding this as well. Are there any specific instances where #fff would be preferable to rgb(255, 255, 255)? Is there any difference other than semantics?

Mark VonGyer
Mark VonGyer
21,239 Points

Yes. In Android you can express alpha immediately infront of a hexidecimal color. In CSS, from what I understand, you cannot.