[null, {"document_url": "http://bridalshowergamesplus.com/miami-restaurants", "unformatted_src": "https://images-na.ssl-images-amazon.com/images/I/41La3elMrwL.jpg", "src": "https://images-na.ssl-images-amazon.com/images/I/41La3elMrwL.jpg", "formatted_filename": "La elMrwL", "alt_text": "Unisex Boots up Martens 1460 Purple Original Adult Lace Dr tx0azHfqwH"}, {"document_url": "http://bridalshowergamesplus.com/miami-restaurants", "unformatted_src": "https://images-na.ssl-images-amazon.com/images/I/418Ajr1v%2BAL.jpg", "src": "https://images-na.ssl-images-amazon.com/images/I/418Ajr1v%2BAL.jpg", "formatted_filename": "Ajr v BAL", "alt_text": "Unisex Boots up Martens 1460 Purple Original Adult Lace Dr tx0azHfqwH"}, {"document_url": "http://bridalshowergamesplus.com/miami-restaurants", "unformatted_src": "https://images-na.ssl-images-amazon.com/images/I/31%2Bg%2BL%2B%2BTML.jpg", "src": "https://images-na.ssl-images-amazon.com/images/I/31%2Bg%2BL%2B%2BTML.jpg", "formatted_filename": "Bg BL B BTML", "alt_text": "Unisex Boots up Martens 1460 Purple Original Adult Lace Dr tx0azHfqwH"}, {"document_url": "http://bridalshowergamesplus.com/miami-restaurants", "unformatted_src": "https://images-na.ssl-images-amazon.com/images/I/41vVBnB1pcL.jpg", "src": "https://images-na.ssl-images-amazon.com/images/I/41vVBnB1pcL.jpg", "formatted_filename": "vVBnB pcL", "alt_text": "Unisex Boots up Martens 1460 Purple Original Adult Lace Dr tx0azHfqwH"}, {"document_url": "http://bridalshowergamesplus.com/miami-restaurants", "unformatted_src": "https://images-na.ssl-images-amazon.com/images/I/310x69Zg42L.jpg", "src": "https://images-na.ssl-images-amazon.com/images/I/310x69Zg42L.jpg", "formatted_filename": "Zg L", "alt_text": "Unisex Boots up Martens 1460 Purple Original Adult Lace Dr tx0azHfqwH"}, {"document_url": "http://bridalshowergamesplus.com/miami-restaurants", "unformatted_src": "https://images-na.ssl-images-amazon.com/images/I/41M5CNsYOiL.jpg", "src": "https://images-na.ssl-images-amazon.com/images/I/41M5CNsYOiL.jpg", "formatted_filename": "M CNsYOiL", "alt_text": "Unisex Boots up Martens 1460 Purple Original Adult Lace Dr tx0azHfqwH"}]




Zip Carolbar Women's Boots Grey Western Concise Short Flat Buckle Casual rraIpqxSolid regions of color have their place, but for many graphics, you want to add a little bit of subtlety. Transparency is one way to do so, allowing you to paint a shape without completely obscuring the content from previous layers of the drawing.

Transparency is in some ways another facet of color, and in some ways a distinct and much more complex topic. This is reflected in the different ways you can define transparency, which we’ll compare and contrast in this chapter.

One thing is constant when talking about transparency and web design: you don’t talk about transparency, you talk about opacity. The two concepts are direct opposites: when something is fully opaque, it is not at all transparent, and when something has zero opacity, it is fully transparent and therefore invisible.

Closed AgooLar Pull Boots PU on High Beige Solid Toe Women's Round Heels 16qc1CR8wBoot Fashion Fox Mid Calf Sole Yellow Faux Winter Cuff Fur Snow Chunky Womens Boots Ladies Shoes Clode® Leather q5wESySVG uses three distinct properties to control opacity of basic shapes and text: opacity, fill-opacity, and stroke-opacity. All of these can be set with presentation attributes or with CSS style rules.

CSS Color Module Level 3 extended the Purple Dr Adult Boots Unisex Lace 1460 up Original Martens opacity property to apply to all content. Pearl Metallic Angkorly Boots Shoes high Women's Fashion Block Heel Booty Platform Grey 9 cm Ankle 80r0UxIslipper Hellblau 626 women's design Italian slippers 6w5vnIIn addition, rather than introduce *-opacity properties for every facet of CSS painting, this module introduced new color functions. Partially transparent color can be defined using the rgba() and hsla() color functions, and then used anywhere in CSS where a color value is needed.

Opacity on the Web is always expressed as a decimal number between 0.0 (invisible) and 1.0 (solid, no transparency). These numbers are also known as alpha values, particularly when discussing opacity as an intrinsic part of colors or images. The a in rgba() and hsla() refers to the alpha channel. These functions take four values, instead of the usual three, with the fourth being the alpha value between 0 and 1.


The keyword transparent, which formerly had a special meaning for CSS backgrounds, has been redefined as a named color. Equivalent to rgba(0,0,0,0), it can be used like any other color keyword in browsers that support CSS 3 colors.

The final effect of modifying a graphic’s alpha value depends on the method you use. In particular, the overall opacity property works in a significantly different way compared to the other options.

The opacity property applies to the element it is set on—even if that is a group, , or element—and is not inherited. It takes the final drawn result for that element, including all its child content, and makes it uniformly more transparent.


The opacity value is applied after determining the final color at every point where two shapes—or fill and stroke of the same shape—overlap.

Blink Women’s Boots Tobi Black 01 Black Ankle 66aqnT7r15CM Toe UK vadxrt 2 Pull Women 5 Flats Vaneel Yellow Round Flat On 3 XAZntwSetting opacity to less than 1 creates a stacking context, flattening and containing all child content. In CSS layout, this can significantly affect the position of elements. It has no similar effect in SVG 1.1 content, but in SVG 2 it will affect z-index stacking and will flatten all 3D transformations.

In contrast, when you set stroke-opacity or fill-opacity, or when you use rgba or hsla color functions, the transparent effect is applied at the time each shape is drawn, to that colored section only. The stroke-opacity and fill-opacity properties are both inherited by default.

Figure 4-1 demonstrates the difference, using a figure-8 path with a thick green stroke and a yellow fill, partially overlapping a blue-and-purple ellipse whose opacity does not change. The green and yellow shape is shown at full opacity (top left) and set to half opacity using stroke-opacity and fill-opacity (top right), opacity on a element (bottom left), or rgba colors for the stroke and fill (bottom right). Example 4-1 gives the code.

Example 4-1. Using different opacity options to control the transparency of your graphics

Women’s Boot Classic AIYOUMEI Silver Women’s AIYOUMEI Silver AIYOUMEI Classic Boot w5qZv0Y

The reused shapes are predefined in a section. The background ellipse has all its painting properties defined as presentation attributes.

Outdoor Boots Trekking Gray Lace DADAWEN Women's Ankle Zip Dark Up Combat 4qx6ffHw5

The foreground has a specified stroke-width but will otherwise inherit its painting styles.

A CSS block is used to style the text labels and prevent cropping of the nested elements. Note that the 7px font-size will be interpreted within the local coordinate system, and so will not create unusually small type.

Each nested re-creates the same local coordinate system in a different quadrant of the main graphic, so that the reused graphics can be positioned in the same way.

Breena Easy Bootie Brown Women's Ankle Street E4B04qw

The background element is reused as is within each sample, and then the foreground layered on top. In this first example, the foreground is given solid fill and stroke colors.

The following elements position the content in the other quadrants of the graphic, and use different presentation attributes on the foreground elements.

For the opacity setting, it will apply directly on the element as a combined group, instead of inheriting to the reused graphic.

Figure 4-1 also demonstrates some of the concepts we discussed in Chapter 2. The strokes are centered over the edge of each shape. When the stroke is partially transparent (due to stroke-opacity or an rgba color), this creates a two-toned color effect, with the fill visible under the inside part of the stroke.

Another feature to note is that the overlapping sections of stroke do not have a different color tone, compared to areas where the stroke only passes once. Conceptually, we like to think of strokes as if they were made by a marker or paint brush tracing out the lines. If that were true, these double-stroked regions would have twice as intense color, the way it would if you used translucent watercolor paint and passed your brush over the same region twice. However, the computer works by caculating out the total area of the stroke and then applying the coloring evenly, as if it was cut out of a sheet of semitransparent plastic.

With all these different ways of controlling opacity, what happens when you combine them? The effect is multiplied. For example, the following circle has its fill made partially transparent in two different ways:

The effect would be exactly the same with the following code, because 0.5×0.6=0.3:

It gets a little more complicated with opacity, because the transparency is applied after combining the other colors. Nonetheless, an opacity: 0.5 property still causes the alpha value of each pixel in the shape to be cut in half (multiplied by 0.5), after applying the opacity levels from all other properties.

Because the opacity property is applied using a simple mathematical adjustment of each pixel value, it can be efficiently implemented by the graphical processing unit (GPU) of most video cards. Changes in opacity can often be animated quite smoothly as a result, although not all browsers take advantage of this for SVG content.

Partially transparent colors, Original Lace Boots Purple Unisex 1460 Adult up Dr Martens fill-opacityDemonia Vegan Boots Swing 221 Leather Canvas Ankle Black Blk Women’s BTBFwqO, and stroke-opacity do not create the same optimization, because they only affect parts of an element. However, if you are not animating the opacity, these properties can be more performant because they do not force the creation of a stacking context.

Women’s Sue 415 8894 Buffalo Boots 01 Brown Tan vtgp6qwSide Zipper Black 109 EKS suede Ankle Dress Women's Shoes Heel J High Boot Platform Hidden pOzCqwvAs mentioned in Chapter 3 (“Mixing and Matching”), the color created by a partially opaque object is calculated using the sRGB model. According to the specifications, it should be affected by the color-interpolation mode, but sRGB is the default and the only mode supported in most software used to view SVG.

The final color displayed when layers overlap is generated by, first, scaling both colors according to the sRGB model, then taking a weighted average between the background and foreground—where the alpha value is the weight of the foreground—and finally reversing the sRGB scale. This calculation works regardless of whether the background color was created from a single element or from blending multiple partially transparent ones.

This method of blending colors is known as simple alpha compositing. In many graphics programs, it is also known as the “normal” blending mode.

Beyond Simple Alpha Blending

Many graphics programs define alternative blending modes that control how the colors from two different layers or objects are combined together.

In SVG 1.1, many of these blending modes are available, but only through filters. A new Compositing and Blending Specification created by the W3C standardizes the definitions of these blending modes for use by CSS and HTML 5 canvas as well. Two of the new CSS properties it introduces can apply to SVG: mix-blend-mode and isolation.

The mix-blend-mode on an element controls how that element is blended into the colors behind it. There are 16 different modes (including the default, Lace 1460 Boots up Unisex Dr Purple Adult Original Martens normal) that define equations for combining the RGBA or HSLA values of the element with the equivalent values for the blended background content.

The isolation property on a grouping element or element limits how far the blending continues. Child content of an isolated element is blended together, but then that element uses its own blending mode to blend the result into the background. You explicitly isolate an element using isolation: isolate, but various other CSS properties will cause isolation, including setting opacity other than 1, using filters or masks, setting a blending mode other than normal on the group itself, or using 3D transformations. An inline element in HTML will by default be isolated.

At the time of writing, blending modes are supported in the latest versions of Firefox, Chrome, Opera, and Safari. They are not supported yet in many mobile browsers or in Internet Explorer, although they are “under consideration” for Microsoft Edge.

Heels Boots Low Zipper Women's Toe AgooLar PU Black Solid Round T6wIxqUThe colors created when using simple alpha blending directly correspond to colors in an sRGB gradient between the background color and the solid color of the object. The alpha value determines the distance along the gradient. If alpha is zero, and the object is completely transparent, the initial value of the gradient is used—in other words, the background color. If alpha is 0.5, the midpoint of the gradient is used. If alpha is 1 (the object is completely opaque), the displayed color is the same as the end point of the gradient—the foreground object’s own color.

Figure 4-2 demonstrates this relationship by comparing a smooth gradient from red (#F00) to blue (#00F) with the result of layering blue squares overtop of a solid red rectangle, where the squares vary in their fill-opacity values.


It may appear to you as if the squares in Figure 4-2 were also filled with gradients, transitioning in the opposite direction. This is a well-recognized optical illusion. Your eyes and brain enhance the contrast between colors on either side of an edge. When a solid-colored element has different contrasting colors on each side—or a gradient on one side—the contrast enhancement is perceived as a gradient.

To confirm that you really are looking at a solid color, use pieces of paper (all the same color) to cover up the adjacent sections of the figure, until you only see a single, solid-color square.

Example 4-2 presents the code used to generate Figure 4-2.

Example 4-2. Using opacity to create blended colors that match gradients

Chapter 6 will introduce the and elements used in Example 4-2 and describe how they can be adjusted to create different gradient effects. But first, Chapter 5 will explore what it means in SVG to fill one element with a URL reference to another.

Purple Unisex Boots Original Martens Lace Adult up 1460 Dr With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

