Page MenuHomePhabricator

Transparent background causes text to be unreadable in dark mode
Open, Needs TriagePublicBUG REPORT

Description

Following up from https://en.wikipedia.org/wiki/Wikipedia:Village_pump_(technical)/Archive_214#Adding_transparency_to_make_templates_more_dark-mode_friendly, transparency allows for quick adaptation of templates that only use inline styles, with not much work. However, because of T358797, the text is incorrectly changed to a fixed color even for dark mode elements.

Steps to replicate the issue (include links if applicable):

I visit a page like https://en.wikipedia.org/w/index.php?title=Wikipedia:Village_pump_(technical)&diff=prev&oldid=1239847115 which has tags with transparent background elements.

What happens?:

The text stays really dark in dark mode, making it unreadable.

What should have happened instead?:

The text should stay white instead.

Software version (on Special:Version page; skip for WMF-hosted wikis like Wikipedia):

Other information (browser name/version, screenshots, etc.):

Using Microsoft Edge.

The temporary "fix" for this is to specify "color:inherit;" in inline CSS for this, but that can also not work.

A more permanent fix would be one of the following: for inline CSS, don't just simply override the text color to make it how a specific user wants it to be. Nevermind selectors like [style*='background'] are more resource intensive on the browser. Instead, it should be a little bit more intelligent to specify the text color to make it readable regardless of what the background is. This also has the advantage that if someone decides to do something like put a black background on their talk page, regardless of whether it is in dark or light mode, the text color can be adjusted dynamically. This is important for accessibility.

Note this has nothing to do with display:transparent; or opacity: these affect the transparency of everything, not just the background. Just when an alpha is specified in the background-color (like in rgba(..., ..., ..., 0.5) or #XXXXXX08).

Event Timeline

I also think of an alternate solution would have been to individually search and replace in the mw-content-text HTML any background CSS that does not specify a background transparency and just add one before serving the CSS, rather than playing with the text colors. Only issue is that if one does not want transparency, one would need to specify an alpha parameter in the CSS colors. There is not really any good solution, and we probably will have to accept it will be a mess until all the templates on Wikimedia are properly ported to use dark mode.