chiark / gitweb /
Add stylesheet to plain text files in .htaccess
authorBen Harris <bjh21@bjh21.me.uk>
Sun, 19 Oct 2025 09:58:17 +0000 (10:58 +0100)
committerBen Harris <bjh21@bjh21.me.uk>
Tue, 13 Jan 2026 21:55:10 +0000 (21:55 +0000)
It turns out that Firefox (version 140 at least) will happily use an
HTTP Link header for a CSS stylesheet on a plain text file.  It works
a bit weirdly because it applies the stylesheet to the HTML conversion
of the file, but that actually means that the existing bedstead.css
works pretty well.

This doesn't work on Chromium, but that's no worse than what we've
already got.

.htaccess

index d2a504de816e80d29101878eb7f2ee44e44cb27a..6ff3a55c38bc707ed0ed11440fced388b069ca52 100644 (file)
--- a/.htaccess
+++ b/.htaccess
@@ -3,6 +3,7 @@ AddType application/xhtml+xml;charset=UTF-8 .xhtml
 AddType font/otf;outlines=CFF .otf
 <FilesMatch "^\p{Lu}+$">
   ForceType text/plain
+  Header add Link "<bedstead.css>; rel=stylesheet type=\"text/css\""
 </FilesMatch>
 AddOutputFilterByType DEFLATE application/xhtml+xml text/css font/otf \
  application/javascript application/wasm \