How to create a transparent DIV in CSS

How to create a transparent DIV in CSS

A webmaster can make use of CSS image opacity property to create a transparent div relatively easily. A transparent div can be created with or without content. When a div is made transparent with content, images and text are also made transparent along with the div. In case the div is made transparent without content, the div alone will be transparent. To create a transparent DIV, you can make use of the CSS techniques listed in the article below.

Create a transparent DIV (with the content)

  • The div itself will be transparent, but the same applies for all other content such as images or text.
  • <div style="filter:alpha(opacity=50); opacity:0.5;">........</div> 
  • The opacity property is taken into account in firefox 3 +, Chrome 2 +, Safari 4 and Opera 10. The filter:alpha(opacity=50) enables Internet Explorer 8 and Opera 9.x to make content transparent.

Create transparent DIV (without the content)

  • Use CSS-property: "rgba"
  • To add color in CSS, use the property rgb (). Soon the function rgba() will be available . The "a" is for the transparency:
  • <div style="background-color: rgba(255, 0, 0, 0.5)">.........</div>
  • Here, the color red will be transparent. This function is not recognized by Internet Explorer or Opera 9.x (works with Opera 10).
Any more CSS questions? Check out our forum!