Cross-Browser CSS Opacity
The ability to make a div element opaque using CSS is useful for creating aseptically pleasing websites and effects. The following code can be used on any CSS element.
Cross-Browser Code
filter: alpha(opacity=50);
-khtml-opacity: 0.5;
-moz-opacity: 0.5;
opacity: 0.5;
Working ExampleIn this example a div element (.box) is centered on the screen using the margin auto code. It is then told its size, width and background color. Finally the element is told to be transparent in IE, Firefox Safari and Konqueror using the code depicted above.
HTML code
<div class= "box"></div>
CSS code
.box {
margin: 0 auto 0 auto;
width: 100px;
height: 100px;
background-color:#000;
filter: alpha(opacity=50);
-khtml-opacity: 0.5;
-moz-opacity: 0.5;
opacity: 0.5;
}Post Info
Leave a Comment
Browse by Category
- Announcements (2)
- Concepts (3)
- CSS News (745)
- CSS Properties (3)
- Design Elements (1)
- Digital Economy News (405)
- Hacks (1)
- Legislation (1)
- PHP Scripts (2)
- University (1)
- Web 2.0 News (903)
- Wordpress Functions (5)


(4 votes, average: 3.50 out of 5)