When I wrote about the new
accent-color property in CSS, I pondered how much control a web developer should have over styling form controls:
Who are we to make that decision? Shouldn’t the user’s choice take primacy over our choices?
But then again, where do we draw the line? We’re allowed over-ride link colours. We’re allowed over-ride font choices.
Ultimately, I came down on the side of granting authors more control:
If developers don’t get a standardised way to customise native form controls, they’ll just recreate their own over-engineered versions.
This question of “who gets to decide?” used to be much more prevelant in the early days of the web. One way to think about this is that there are three stakeholders involved in the presentation of a web page:
- The author of the page. “Author” is spec-speak for designer or developer.
- The user.
- The browser, or user agent. A piece of software tries to balance the needs of both author and user. But, as the name implies, the user takes precedence.
These days we tend to think of web design a single-stakeholder undertaking. The author decides how something should be presented and then executes that decision using CSS.
But as Eric once said, every line of you CSS you write is a suggestion to the browser. That’s not how we think about CSS though. We think of CSS like a series of instructions rather than suggestions. Never mind respecting the user’s preferences; one of the first things we do is reset all the user agent’s styles.
In the early days of the web, more consideration was given to the idea of style suggestions rather than instructions. Heck, users could always over-ride any of your suggestions with their own user stylesheet. These days, users would need to install a browser extension to do the same thing.
The first proposal for CSS had a concept called “influence”:
h2.font.size = 20pt 40%
Here, the requested influence is reduced to 40%. If a style sheet later in the cascade also requests influence over h2.font.size, up to 60% can be granted. When the document is rendered, a weighted average of the two requests is calculated, and the final font size is determined.
I think the only remnant of “influence” left in CSS is accidental. It’s in the specificity of selectors …and the
I think it’s a shame that user stylesheets are no longer a thing. But I get why they were dropped from browsers. They date from a time when it was mostly nerds using the web, before “regular folks” came on board. I understand why it became a little-used feature, suitable for being dropped. But the principle of it still rankles slightly.
But in recent years there has been a slight return to the multi-stakeholder concept of styling websites. Thanks to
prefers-color-scheme, a responsible author can choose to bow to the wishes of the user.
I was reminded of this when I added a dark mode to my website:
Y’know, when I first heard about Apple adding dark mode to their OS—and also to CSS—I thought, “Oh, great, Apple are making shit up again!” But then I realised that, like user style sheets, this is one more reminder to designers and developers that they don’t get the last word—users do.