Opacity CSS that works for all browsers?

Erik picture Erik · Apr 12, 2011 · Viewed 16.5k times · Source

Can someone recommend the safest approach for giving an OPACITY VALUE to a DIV TAG using CSS?

Erik

Answer

Justin Niessner picture Justin Niessner · Apr 12, 2011

Straight from Css-Tricks.com (this covers everything I can think of):

.transparent_class {
  /* IE 8 */
  -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=50)";

  /* IE 5-7 */
  filter: alpha(opacity=50);

  /* Netscape */
  -moz-opacity: 0.5;

  /* Safari 1.x */
  -khtml-opacity: 0.5;

  /* Good browsers */
  opacity: 0.5;
}