CSS opacity property



The CSS opacity property is used to define the transparancy of an HTML element.opacity property spec the clarity of the image or text.

div {
    opacity: 0.5;
}

text opacity CSS

Example

<!DOCTYPE html>
    <html>
    <head>
    <title>opacity</title>
    <style>
        h1 {
            opacity: 0.7;
        }
    </style>
    </head>
    <body>
      <h1>Heading </h1>
    </body>
    </html>
    


Click on the "Run This Code" button to see how it works.


background image opacity CSS

Example

<!DOCTYPE html>  
<html>  
<head>  
<style>  
img.trans {  
    opacity: 0.4;  
    filter: alpha(opacity=40);  
}  
</style>  
</head>  
<body>  
<p>Normal Image</p>  
<img src="code.png" alt="normal image">  
<p>Transparent Image</p>  
<img class="trans" src="code.png" alt="transparent image">  
</body>  
</html>  

 


Click on the "Run This Code" button to see how it works.





CSS

Welcome CSS Syntax CSS Selectors CSS ADD css CSS Borders CSS Backgrounds CSS Colors CSS Padding CSS Margin CSS Fonts CSS Text CSS Outline CSS Box-Model CSS Height&Width CSS Icons CSS Links CSS Lists CSS Display CSS Tables CSS Position CSS Overflow CSS Align CSS Float CSS Inline-block CSS Opacity CSS Image-Gallery CSS Navigation Bar CSS Dropdowns CSS Cursors CSS Forms CSS Pseudo-classes CSS Pseudo-elements

CSS3 FEATURES

CSS Gradients CSS shadows CSS 2D Transforms CSS 3D Transforms CSS Animations CSS Media Queries CSS Flexbox CSS important CSS Units