Transparent DIV SPAN for all browsers

To make an HTML element transparent. Just use these css elements in your css class.  filter, moz-opacity, opacity.

Internet Explorer uses filter and firefox uses moz-opacity.

.transparent
{
   filter:alpha(opacity=60); 
   -moz-opacity: 0.6; 
   opacity: 0.6; 
}

<div class="transparent">A transparent div.
</div>

The opacity value changes from 0 to 1.

10 Comments

  1. Cale:

    excellent bit of info there it really helped to make transparent divs that work on both firefox and IE thankyou :)

  2. Marcos Buarque:

    Hi, good short tutorial. What is the solution when I need the text within the DIV to be 100% opaque over, let’s say, a 60% transparency DIV? As far as I could see testing, the text gets faded in the same scale as the div even if I put a 100% opaque tag inside the DIV. Thanks.

  3. Amidala.be: insanity leads to poetry … or just a weblog. » Blog Archive » My del.icio.us bookmarks for June 5th through July 24th:

    […] Transparent DIV SPAN for all browsers | Can Erten - […]

  4. Peri:

    Wow, it works, excellent!
    Do you mind if I share and translate this to another language on my blog?

    Many thanks :)

  5. Peri Net » [CSS] Membuat Layer DIV Transparan yang Sukses di Semua Browser:

    […] Terimakasih Can Erten! […]

  6. Can:

    You are very welcome indeed. :)

  7. Hebbarus:

    Good stuff! Just what I was looking for. Works great!

  8. Johnny Russell:

    What I do if I want to make a div with a transparent background but have text show up opaque is I make two divs with identical properties. Then, I take one div, put it behind the other, and make it transparent. Then, I put all of my content in the other div. Therefore, one div is used for content and is opaque; the other div is used for the background and is transparent. That’s just what I do. There may be a better way.

    Que te vaya bien.

  9. riri:

    thanks, simple & easy, it’s works!

  10. Chris:

    Great example. I’d only note that Firefox now simply supports “opacity”, so you don’t have to use “-moz-opacity” anymore.

Leave a comment