Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between opacity and that through alpha channel (rgba)?

Tags:

div { background-color: rgb(255,0,0); opacity: 1; }  div { background-color: rgba(255,0,0,1); } 

What is the difference between the above two?

like image 772
Sreehari K M Avatar asked Jan 10 '13 05:01

Sreehari K M


People also ask

What is the difference between alpha and opacity?

The opacity-level describes the transparency-level, where 1 is not transparant at all, 0.5 is 50% see-through, and 0 is completely transparent. Alpha Channel RGBA color values are an extension of RGB color values with an alpha channel - which specifies the opacity of the object.

What's the difference between using opacity and rgba transparency in CSS?

The primary difference is, the opacity applies to its sub-elements too. In contrast, rgba() applies the transparency of the colour to that particular element only. For example, opacity is set to the div element that contains text and has a border.

Is alpha transparency or opacity?

The alpha channel contains no color information, only transparency information. The channel is always visualized as a grayscale image.

What is the difference between transparency and opacity?

In digital photography, transparency is the functionality that supports transparent areas in an image or image layer. Certain image formats do not support transparency. Opacity is the extent to which something blocks light.


2 Answers

Opacity sets the opacity value for an element and all of its children; While RGBA sets the opacity value only for a single declaration.

This is well explained here. http://www.css3.info/introduction-opacity-rgba/

like image 68
Krishna Prasad Varma Avatar answered Oct 12 '22 09:10

Krishna Prasad Varma


Opacity : The opacity property sets the opacity level for an element.(Setting opacity for an elements makes the whole element transparent including its content.)

Defining opacity:

element{opacity:0.5} //makes the element and it's content 50% transparent 

The opacity-level describes the transparency-level, where 1 is not transparant at all, 0.5 is 50% see-through, and 0 is completely transparent.

Alpha Channel RGBA color values are an extension of RGB color values with an alpha channel - which specifies the opacity of the object. Background : rgba (Red,Green,Blue,Opacity) (Setting rgba of an element only makes the element background transparent leaving its content as it is.)

Defining Background rgba: background:

element{    background:rgba(40, 41, 42, 0.5); } 

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

To convert a hex value of color to rgb: Here

Further Info:

RGBA color values are supported in IE9+, Firefox 3+, Chrome, Safari, and in Opera 10+.

like image 37
Suman KC Avatar answered Oct 12 '22 11:10

Suman KC