:: krowemoh

Friday | 13 DEC 2024
Posts Links Other About Now

previous
next

Set Custom CSS

2022-02-10

My blog is feeling a little bare but I didn't want to do any styling. I like the default browser look and besides setting a max width on the body, I like that I don't have to maintain anything.

I also would love to have an always open notepad to edit the styles. I think this would be pretty useful in general for most sites. Instead of manually zooming in, I could just write a style to change the font size or line height. So I tried implementing something like that for my blog.

I wrote the change css page:

https://nivethan.dev/css.html

This will let you enter styles in the textarea and then it will save it to the localstorage and add it to the page. This way the user can define their own styles and view the site the way they want to. There is something quite nice about that idea even though I doubt anyone would actually do something with it.

Ultimately, even though it is mostly implemented and now I just need to add the logic to every page to check localstorage for styles, I decided to not actually follow through. I don't want to run javascript for a blog as I think I might be going in the wrong direction. I want to keep things simple and manageable and this I think would be a step in a direction that adds complexity.

So for now, the change css page only affects itself.

I had fun writing up this little toy. It's some very simple html and javascript and everything is in one file. All it does is take the textarea content and sticks it in style tags which then get added to the documents head.

There is a certain amount of privilege in proposing something like this, after all I'm comfortable using CSS and know most of the options and so I can re-style things to suit me but someone who doesn't know, won't be able to and they might get a sub par experience of a site if everyone left styling up to the user. This however would also force code literacy which might be a good thing ultimately. I also imagine importing styles would also be pretty easy.

This is something I could probably implement for my site and with a proper backend, I don't need to use javascript and can save css per user in the database. I'll need to think about it as I think there is something to be said about having just one UI.