PHPfied CSS?

I didn't really expect it but hey it works

I was this years old to know aside of HTML, you can also convert CSS file to PHP in order to use some PHP shenanigans. Just add a header to indicate that it’s of type text/css:

1
2
3
4
5
6
7
8
<?php header("Content-Type: text/css"); ?>
@import url('../styles.css?v=<?=filemtime('../styles.css')?>');

.category-header {
    background-color: var(--color-bg-alt);
    backdrop-filter: blur(5px);
    ...
}

and inside the HTML file you can link the stylesheet like usual, except changing the .css to .php

1
<link rel="stylesheet" href="gallery.php" />

Wild.

Licensed under CC BY-NC-SA 4.0
Last updated on Jan 15, 2026 06:43 +0800
Built with Hugo
Theme Stack designed by Jimmy