Okay, this is a neat idea but also probably highly foolish: using CSS as a content API. We’ll get to that. But first: in Custom Properties as State, Chris writes about Seasonal.css which “supplies a seasonal colour scheme based on the day of the year.”
And then use the variables within this CSS file to style your site. All of the variables in that file are then updated for every day of the year as they show on the example website:
Chris looks at all this and then writes:
This makes me think that a CDN-hosted CSS file like this could have other useful stuff, like today’s date for usage in pseudo content, or other special time-sensitive stuff. Maybe the phase of the moon? Sports scores?! Soup of the day?!
It’s almost like a data API that is tremendously easy to use. Pseudo content is even accessible content these days — but you can’t select the text of pseudo-elements, so don’t read this as an actual endorsement of using CSS as a content API.
Simon Willison took that idea and ran (caveating it all as a very weird idea) building an API for arbitrary database queries that return the results as… CSS custom properties. 🤯