
- CSS Tutorial
- CSS - Home
- CSS - Introduction
- CSS - Syntax
- CSS - Inclusion
- CSS - Measurement Units
- CSS - Colors
- CSS - Backgrounds
- CSS - Fonts
- CSS - Text
- CSS - Images
- CSS - Links
- CSS - Tables
- CSS - Borders
- CSS - Margins
- CSS - Lists
- CSS - Padding
- CSS - Cursors
- CSS - Outlines
- CSS - Dimension
- CSS - Scrollbars
- CSS Advanced
- CSS - Visibility
- CSS - Positioning
- CSS - Layers
- CSS - Pseudo Classes
- CSS - Pseudo Elements
- CSS - @ Rules
- CSS - Text Effects
- CSS - Media Types
- CSS - Paged Media
- CSS - Aural Media
- CSS - Printing
- CSS - Layouts
- CSS - Validations
- CSS3 Tutorial
- CSS3 - Tutorial
- CSS3 - Rounded Corner
- CSS3 - Border Images
- CSS3 - Multi Background
- CSS3 - Color
- CSS3 - Gradients
- CSS3 - Shadow
- CSS3 - Text
- CSS3 - Web font
- CSS3 - 2d transform
- CSS3 - 3d transform
- CSS3 - Animation
- CSS3 - Multi columns
- CSS3 - User Interface
- CSS3 - Box Sizing
- CSS Responsive
- CSS - Responsive Web Design
- CSS References
- CSS - Questions and Answers
- CSS - Quick Guide
- CSS - References
- CSS - Color References
- CSS - Web browser References
- CSS - Web safe fonts
- CSS - Units
- CSS - Animation
- CSS Resources
- CSS - Useful Resources
- CSS - Discussion
CSS Opacity that Works in All Browsers
The property opacity is the modern solution and works for Firefox 0.9+ , Safari 2, opera 9+, IE 9+ and every version of chrome. The -moz-opacity property is the opacity property for Firefox versions older than 0.9 while the –khtml-opacity property is for safari versions starting with 1. The filter property is for IE browsers from 5 to 9 to give opacity like effect. Using all these values together as a fallback for modern opacity allows us to use opacity in all browsers.
Following is code for having image opacity using CSS that works in all browsers −
Example
<!DOCTYPE html> <html> <head> <style> body { font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif; } img { width: 270px; height: 200px; } .transparent { filter: alpha(opacity=30); -moz-opacity: 0.3; -khtml-opacity: 0.3; opacity: 0.3; } </style> </head> <body> <h1>Opacity for all browsers</h1> <img src="https://i.picsum.photos/id/305/800/800.jpg" /> <img class="transparent" src="https://i.picsum.photos/id/305/800/800.jpg" /> <h3>The second image above will get opaque on all browsers</h3> </body> </html>
Output
The above code will produce the following output −
- Related Articles
- CSS Image Opacity for All Web Browsers including IE 8 and less
- CSS Opacity / Transparency
- How can I vertically center a div element for all browsers using CSS?
- Perform Animation on CSS opacity
- CSS Opacity in Firefox, Safari, Chrome, Opera
- Setting Cross Browser Opacity using CSS
- Creating Browsers Window using HTML and CSS
- Usage of -moz-opacity property with CSS
- How to set color opacity with RGBA in CSS?
- Set the opacity of an image with CSS
- Set the opacity for the background color with CSS
- Disabling Pull-to-Refresh Feature on Mobile Browsers using CSS
- Set the opacity only to background color not on the text in CSS
- How to align checkbox and its label on cross-browsers using CSS?
- How to set the opacity level for a division element using CSS?

Advertisements