{"id":14083,"date":"2011-09-05T20:56:01","date_gmt":"2011-09-06T03:56:01","guid":{"rendered":"http:\/\/css-tricks.com\/?page_id=14083"},"modified":"2016-02-23T14:23:13","modified_gmt":"2016-02-23T21:23:13","slug":"opacity","status":"publish","type":"page","link":"https:\/\/css-tricks.com\/almanac\/properties\/o\/opacity\/","title":{"rendered":"opacity"},"content":{"rendered":"
The Basic use:<\/p>\n Opacity has a default initial value of 1 (100% opaque). Opacity is not inherited, but because the parent has opacity that applies to everything within it. You cannot make a child element less transparent than the parent, without some trickery<\/a>. Values are a number from 0 to 1 representing the opacity of the channel (the “alpha” channel). When an element has a value of 0 the element is completely invisible; a value of 1 is completely opaque (solid).<\/p>\n If you want opacity to work in all versions of IE<\/a>, the order should be as follows:<\/p>\n If you don\u2019t use this order, IE8-as-IE7 doesn\u2019t apply the opacity, although IE8 and a pure IE7 do.<\/em><\/p>\n If an element with Opacity can be used as an alternative to the The opacity property in CSS specifies how transparent an element is. Basic use: div { opacity: 0.5; } Opacity has […]<\/p>\n","protected":false},"author":1036,"featured_media":0,"parent":13939,"menu_order":0,"comment_status":"open","ping_status":"closed","template":"page-almanac-single.php","meta":{"_acf_changed":false,"_bbp_topic_count":0,"_bbp_reply_count":0,"_bbp_total_topic_count":0,"_bbp_total_reply_count":0,"_bbp_voice_count":0,"_bbp_anonymous_reply_count":0,"_bbp_topic_count_hidden":0,"_bbp_reply_count_hidden":0,"_bbp_forum_subforum_count":0,"sig_custom_text":"","sig_image_type":"featured-image","sig_custom_image":0,"sig_is_disabled":false,"inline_featured_image":false,"c2c_always_allow_admin_comments":false,"footnotes":"","_share_on_mastodon":"0","_share_on_mastodon_status":"%title% %permalink%"},"tags":[],"acf":[],"share_on_mastodon":{"url":"","error":""},"jetpack_sharing_enabled":true,"jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/pages\/14083"}],"collection":[{"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/users\/1036"}],"replies":[{"embeddable":true,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/comments?post=14083"}],"version-history":[{"count":10,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/pages\/14083\/revisions"}],"predecessor-version":[{"id":238350,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/pages\/14083\/revisions\/238350"}],"up":[{"embeddable":true,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/pages\/13939"}],"wp:attachment":[{"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/media?parent=14083"}],"wp:term":[{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/tags?post=14083"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}opacity<\/code> property in CSS<\/abbr> specifies how transparent<\/em> an element is. <\/p>\n
div {\r\n opacity: 0.5;\r\n}<\/code><\/pre>\n
<\/code>Check out this Pen!<\/a><\/pre>\n
IE Compatibility<\/h3>\n
.opaque {\r\n \/* Theoretically for IE 8 & 9 (more valid) *\/\r\n \/* ...but not required as filter works too *\/\r\n \/* should come BEFORE filter *\/\r\n -ms-filter:\"progid:DXImageTransform.Microsoft.Alpha(Opacity=50)\"; \/\/ IE8\r\n\r\n \/* This works in IE 8 & 9 too *\/\r\n \/* ... but also 5, 6, 7 *\/\r\n filter: alpha(opacity=50); \/\/ IE 5-7\r\n \r\n \/* Modern Browsers *\/\r\n opacity: 0.5;\r\n}<\/code><\/pre>\n
Note on Stacking Contexts<\/h3>\n
opacity<\/code> and a value less than 1 is positioned, the
z-index<\/code><\/a> property applies as described in CSS2.1, except that the
auto<\/code> value is treated as 0 since a new stacking context is always created.<\/p>\n
visibility<\/code><\/a> property:
visibility: hidden;<\/code> is just like
opacity: 0;<\/code>.<\/p>\n
Related Properties<\/h3>\n
\n
Other Resources<\/h3>\n
\n
Browser Support<\/h3>\n
\n\n
\n Chrome<\/span><\/th>\n Safari<\/span><\/th>\n Firefox<\/span><\/th>\n Opera<\/span><\/th>\n IE<\/span><\/th>\n Android<\/span><\/th>\n iOS<\/span><\/th>\n<\/tr>\n<\/thead>\n\n \n 24+<\/td>\n 5.1+<\/td>\n 19+<\/td>\n 12.1+<\/td>\n 9+<\/td>\n 2.1+<\/td>\n 3.2+<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n","protected":false},"excerpt":{"rendered":"