{"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 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, […]<\/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":{"_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":""},"tags":[],"acf":[],"jetpack-related-posts":[{"id":319912,"url":"https:\/\/css-tricks.com\/almanac\/properties\/s\/shape-image-threshold\/","url_meta":{"origin":14083,"position":0},"title":"shape-image-threshold","date":"August 27, 2020","format":false,"excerpt":"The CSS shape-image-threshold property sets which pixels are included in the shape of an image when shape-outside is used to define the float area of a CSS element. Let's say we're using a linear gradient to define the float area of a CSS shape. Something like this where we go\u2026","rel":"","context":"Similar post","img":{"alt_text":"","src":"https:\/\/i0.wp.com\/css-tricks.com\/wp-content\/uploads\/2020\/08\/gradient-to-transparent.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":161605,"url":"https:\/\/css-tricks.com\/almanac\/properties\/f\/filter\/","url_meta":{"origin":14083,"position":1},"title":"filter","date":"February 18, 2014","format":false,"excerpt":"CSS Filters are a powerful tool that authors can use to achieve varying visual effects (sort of like Photoshop filters for the browser). The CSS filter property provides access to effects like blur or color shifting on an element\u2019s rendering before the element is displayed. Filters are commonly used to\u2026","rel":"","context":"In \"filter\"","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":14029,"url":"https:\/\/css-tricks.com\/almanac\/properties\/c\/color\/","url_meta":{"origin":14083,"position":2},"title":"color","date":"September 5, 2011","format":false,"excerpt":"The color property in CSS sets the color of text and text decorations. p { color: blue; } Values The color property can accept any CSS color value. Named colors: for example, \"aqua\". Hex colors: for example, #00FFFF or #0FF. RGB and RGBa colors: for example, rgb(0, 255, 255) and\u2026","rel":"","context":"Similar post","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":3243,"url":"https:\/\/css-tricks.com\/snippets\/css\/cross-browser-opacity\/","url_meta":{"origin":14083,"position":3},"title":"Cross Browser Opacity","date":"August 6, 2009","format":false,"excerpt":"These days, you really don't have to worry about opacity being a difficult thing cross-browser. You just use the opacity property, like this: .thing { opacity: 0.5; } 0 is totally transparent (will not be visible at all, like visibility: hidden;) and 1 is totally opaque (default). Anything in between\u2026","rel":"","context":"In "Article"","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":17657,"url":"https:\/\/css-tricks.com\/snippets\/css\/transparent-background-images\/","url_meta":{"origin":14083,"position":4},"title":"Transparent Background Images","date":"August 5, 2012","format":false,"excerpt":"There is no background-opacity property in CSS, but you can fake it by inserting a pseudo element with regular opacity the exact size of the element behind it. div { width: 200px; height: 200px; display: block; position: relative; } div::after { content: \"\"; background: url(image.jpg); opacity: 0.5; top: 0; left:\u2026","rel":"","context":"With 87 comments","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":192756,"url":"https:\/\/css-tricks.com\/snippets\/sass\/black-white-opacity-mixins\/","url_meta":{"origin":14083,"position":5},"title":"Black and White Opacity Functions","date":"January 9, 2015","format":false,"excerpt":"It's pretty common to need a bit of transparent black or white. In CSS, you can do: .half-black { background: rgba(0, 0, 0, 0.5); } It gets easier in Sass, where you can substitute a color name: .half-black { background: rgba(black, 0.5); } Or make it easier still, by making\u2026","rel":"","context":"Similar post","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"_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":"