Chapter 4. Becoming Transparent
Solid 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.
See-Through Styles
SVG 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 opacity property to apply to all content. In 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, ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access