There are several ways to achieve the effect of background transparency. I will put them into a short list and later show ways to adapt them to work under Internet Explorer browsers. Of course one could ponder whether or not wrestling with IE is even worth, now that IE9 is released (or should I say “upon us” ;). Well… it is worth it. A strong percentage of users visiting my website are still using IE7 and it’s going to be several years until their number is low enough to justify ignoring them.
Ways to achieve transparency:
CSS
1. DIV#element { background: rgba(200, 54, 54, 0.5); }
Works in all major browsers except IE. Is part of the CSS3 specification and in the perfect world we won’t need anything else.
2. DIV#element { opacity:0.5; filter:alpha(opacity=50); }
The opacity property makes the whole element opaque / transparent. Both content and background. As such it affects the readability of the content. You can change it by stacking two layers of elements on top of each other and making the bottommost one opaque. Not worth the hassle. What it’s good at is hiding content and that’s how I’m hiding the background of my website.
3. DIV#element { background: url(‘transparent_image.png’); }
Using a transparent image as the background is cross-browser compatibile (ekhem, except IE6). You need to prepare it beforehand of course.
Continue reading →