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

What is the definition of "function" being applied when you say RGBA function?

I'm not finding an appropriate definition. I keep getting pointed to Javascript functions but this is definitely not that. So, I am just wondering what the definition of "function" is in the context?

3 Answers

Seth Kroger
Seth Kroger
56,413 Points

"Function" is a general programming/math term that basically means take one or more values, do some steps/computation with them, and send back ("return") the result. They are usually indicated by a function name followed by the inputs inside parentheses:

result = function(input1, input 2, ...)

In this case the rgba() is a function that takes 4 separate color component values and returns a combined color.

Thanks Seth! That answers my question!

Hi Cameron, Usually when you use RGBA, this is a way of telling the browser "Hey, I want this much Red, this much Green, and this much Blue, oh and I want it a little bit transparent". So in essence, the RGBA function would return a usable color for the CSS engine to use. Take a look at the example below.

.my-transparent-color{
background-color: rgba(255, 0, 0, 0.3);
}

The following is a snippet from W3Schools about the Alpha parameter;

The alpha parameter is a number between 0.0 (fully transparent) and 1.0 (fully opaque).

Thanks Jorge! I think I'm not being super clear. I'm trying to find out what the word, "function" means in this context. I might be being thick but I just want to be sure I have it down.

Ali Amirazizi
Ali Amirazizi
16,087 Points

Hi Cameron, RGBA is a CSS function that returns a color(output) based on a given input value(255, 0, 0, 0.3) . It means you enter a value into it and it outputs a result. Also keep in mind functions are not only reserved for javascript per say. They are found everywhere. In math you have functions like square root. In programming languages you can create your own functions. In CSS there are pre-build functions like RGBA. Hope that answers your question.

Thanks Ali, that helps!