Open cbirdsong opened 2 years ago
See also #40943.
Personal opinion: I don't think there's anything wrong with colors defined like #rrggbbaa
... 8-digit hex colors are supported by any and all browsers that WordPress supports. Gutenberg uses many modern CSS techniques such as calc()
, :where()
, CSS grids, flexbox and so on. None of them has 100% support... Flex has 96% support, while :where()
is at 89.14% yet it's used everywhere - and rightly so.
We will never be at 100%, nor should we pursue such a thing if we really want to move forward and build for the next decade.
WordPress’ only explicit list of browser support was intended to apply to the admin area, not the front end of the site. See this discussion on CSS authoring practices and browser support:
However, the difference between those examples and this specific issue is that :where()
and custom properties are (mostly) being used to solve problems with no existing easy solution[^1], while #rrggbbaa
‘s use provides no benefit in comparison to an older more well-supported color format. There is no trade-off being made. It is only exclusionary.
[^1]: However, the implementation could be a lot better. It is best practice to supply fallback values when using modern CSS techniques, but there seems to be very little consideration of progressive enhancement in the CSS that ships with the editor. The end result of this is definitely problematic when considering how heavily :where()
and custom properties are used.
Description
Colors are output as hex values with transparency (
#rrggbbaa
) when using the new opacity control[^1]:This format has less support than
rgba()
(~92% of recorded traffic compared to presumably almost 100%) and offers no tangible benefit over it. Absent that,rgba()
should be preferred.Additionally,
rgba()
is already what is generated for custom gradients:Simple color fills should behave the same way.
[^1]: And possibly other places I haven't noticed?
Step-by-step reproduction instructions
Set a color on a block, adjust the opacity, and look at the resulting markup.
Environment info
WordPress 6.0
Please confirm that you have searched existing issues in the repo.
Yes
Please confirm that you have tested with all plugins deactivated except Gutenberg.
Yes