Managing crossbrowser opacity with CSS

Sometimes you may want to change the opacity of some images with CSS.
There are different ways to do it, according to the browser you are using. In this example, we'll see both Explorer and Firefox.

Firefox

In Firefox, the style is -moz opacity: xx where xx is a number from 0 to 1, where lesser equates to more transparency (basically, it's the alpha).

HTML:
  1. <img style="-moz-opacity:0.5" src="/images/google_logo.gif">

The above image should look solid in Explorer and 50% transparent in Firefox.

Explorer

In Explorer, the style is filter: alpha(opacity=xx) where xx is a number between 0 and 100 (again, it's the alpha)

HTML:
  1. <img style="filter: alpha(opacity=50)" src="/images/google_logo.gif">

The above image should look solid in Firefox and 50% transparent in Explorer.

Firefox and Explorer

To create an image with transparency both in Firefox and Explorer, you need to use both styles

HTML:
  1. <img style="filter: alpha(opacity=50); -moz-opacity:0.5" src="/images/google_logo.gif">

This image should look 50% transparent in Explorer and in Firefox.

Improve the blog rating this post
Tell me what do you think about this post. I'll write better and better entries.
1 Star2 Stars3 Stars4 Stars5 Stars (1 votes, average: 5 out of 5)
Loading ... Loading ...

» Template Monster offers you a great assortment of CSS Templates.
They can be a great start to launch a website of your own and meet the individual needs of your project.

4 Responses to “Managing crossbrowser opacity with CSS”

  1. Shyam Kushwaha on May 9th, 2007 6:24 am

    These codes are Not working in OPERA. How we can manage opacity in opera browser?

  2. vincent on September 11th, 2007 5:06 pm

    Opera has not yet support the opacity standard from the beginning Opera support the CSS 3 opacity, not to support its private Alpha transparent attributes

  3. Fred Timajo on April 9th, 2008 9:14 am

    For opera:

  4. Fred Timajo on April 9th, 2008 9:15 am

    For Opera: style=”opacity:0.5;”

    Note:
    Sorry for the previous reply..

Leave a Reply