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

rgba value how we can use it? and what is the best value for coloring

Q1 in which way we can use rgba is it the lightning fo the tex or anything

Q2 and what's the best value for coloring is it the rgba or (color name) or hexdicmal value

1 Answer

17,610 Points

Hey John,

Q1) RGBA can be used almost anywhere a color in css can be used. So that means RGBA can be a background color, it can be a text color, etc. Just the places where you put in color, you can swap in a RGBA value instead of the hex value or the string for the color.

Q2) It really all depends on your personal preference. For the most part, hex values and RGB values are exactly the same, meaning that you can get the same exact color values from both. So there's really not much difference between them. Most of the time people use some sort of graphic software and they get their colors in a value from that software. So Sometimes people get a hex value or an RGB value from something like Photoshop. Whichever value they get, that's the type of value they use in CSS.

HOWEVER, RGBA give you an extra value called alpha that lets you control the opacity of the color (how transparent it is). This is a step up from the hex value so sometimes people favor RGBA when picking colors, because they can change how transparent it is easily. If you tried to do something like this with a hex value, you would have to create the transparent color through another hex value, rather than just changing a single number.

Look more into RGBA online to see what I mean: