Every CSS color system has an optional alpha component that can define a color’s level of transparency. For example, to produce a background color of red that is halfway transparent for a
<div> with an
genera, we could write:
The CSS named color system is notoriously bad: keywords are often difficult to remember (navajowhite), illogical (darkgrey actually displays lighter than dimgray) and/or visually questionable (lime and fuchsia verge on the bilious).
Until CSS custom named hues and variables are widely supported, preprocessors remain the best way to create your own custom color names. Defining site colors in Sass creates a cohesive color library that can be used to style content quickly and easily, with named colors that are significantly easier to remember and type than their hex equivalents. However, it can be burdensome to build a decent color library with a logical naming system.
Cet article est également disponible en français
CSS variables are slowly making their way from initial draft to browser implementation. But one variable has existed in the specification for years:
currentColor. This CSS feature has good browser support and some practical applications, so now is an excellent opportunity to learn how to use it.