---
title: "What is Opacity in CSS (Cascading Style Sheet)?"  
description: "What is Opacity in CSS (Cascading Style Sheet)?"  
author: "Abhishek Srivasatava"  
published: 2016-10-14  
updated: 2020-09-17  
canonical: https://www.mindstick.com/interview/23086/what-is-opacity-in-css-cascading-style-sheet  
category: "css-css3"  
tags: ["css"]  
reading_time: 2 minutes  

---

# What is Opacity in CSS (Cascading Style Sheet)?

It can be define as the transparency of any image, block etc.\

For defining opacity in CSS we need to remember keyword OPACITY ( Filter it is used in internet explorer.)

```
Img {Opacity: 0.5Filter: alpha (opacity =50)}
```

Opacity value can be in between 0-1.

It can be use for hover case.

How it can be use in the CSS programming?

```
Img:hover{Opacity:1.0}
```

**Writing some text in inside transparent box**

```
<!DOCTYPE html><html><head><style>div.backgnd {  background: red;  border: 2px solid black;}div.boxtrns {  margin: 30px;  background-color: blue;  border: 1px solid black;  opacity: 0.6;  filter: alpha(opacity=60); /* For IE8 and earlier */}div.transbox p {  margin: 20px;  font-weight: bold;  color: green;}</style></head><body><div class="backgnd">  <div class="boxtrns">    <p>Text of transparaent block</p>  </div></div></body></html>
```

\

## Answers

### Answer by Abhishek Srivasatava

It can be define as the transparency of any image, block etc.\

For defining opacity in CSS we need to remember keyword OPACITY ( Filter it is used in internet explorer.)

```
Img {Opacity: 0.5Filter: alpha (opacity =50)}
```

Opacity value can be in between 0-1.

It can be use for hover case.

How it can be use in the CSS programming?

```
Img:hover{Opacity:1.0}
```

**Writing some text in inside transparent box**

```
<!DOCTYPE html><html><head><style>div.backgnd {  background: red;  border: 2px solid black;}div.boxtrns {  margin: 30px;  background-color: blue;  border: 1px solid black;  opacity: 0.6;  filter: alpha(opacity=60); /* For IE8 and earlier */}div.transbox p {  margin: 20px;  font-weight: bold;  color: green;}</style></head><body><div class="backgnd">  <div class="boxtrns">    <p>Text of transparaent block</p>  </div></div></body></html>
```

\


---

Original Source: https://www.mindstick.com/interview/23086/what-is-opacity-in-css-cascading-style-sheet

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
