Re:Imagining CSS for URLs and HTTP Headers
by zffr on Monday November 28, 2022 @11:45AM
(#33775868)
You can simulate this today by having your webserver add HTML attributes for the HTTP headers, domain, path, etc to the body element. It should then be possible to write CSS selectors like the one in the article
[ Parent
| on HN ]
Re:Imagining CSS for URLs and HTTP Headers
by jaywalk on Monday November 28, 2022 @12:44PM
(#33776739)
The author specifically mentions static websites, which wouldn't have the functionality to alter the HTML.
Re:Imagining CSS for URLs and HTTP Headers
by superkuh on Monday November 28, 2022 @01:11PM
(#33777167)
You can specify HTTP headers for a path/location in nginx in a static website and have it include arbitrary headers. Most standards respecting browsers (like Firefox) accept HTTP header specified CSS like,
#/etc/nginx/sites-enabled/whatever.conf
location /this-isnt-for-you.html {
add_header Link "<//site.com/isntforyouheader.css>; REL=stylesheet";
}
$ curl -I http://site.com/this-isnt-for-you.html
curl -I site.com
HTTP/1.1 200 OK
Server: nginx
Date: Mon, 28 Nov 2022 18:08:01 GMT
Content-Type: text/html
Connection: keep-alive
Link: <//site.com/isntforyouheader.css>; REL=stylesheet
...
This works to set CSS atributes only for a specific URL on my static websites using .html files. For nginx. But nginx is a very common and secure choice for static sites and available in everyone's repos. And you can probably add arbitrary headers per path with other static webservers configs too.
Re:Imagining CSS for URLs and HTTP Headers
by anentropic on Monday November 28, 2022 @12:54PM
(#33776906)
if it's served via a CDN then it may be possible there, they often have facilities to transform the content based on headers etc