Dynamic CSS

I’ve been thinking today about how best to dynamically introduce CSS into a website. For example, a blog engine like WordPress.com or Blogger has the ability to let users edit CSS “files” which are then applied to the website dynamically. I say “files” in air-quotes because I don’t know yet if they actually edit a hard file, or if the “file” is a stream of data stored in a database, or what.

For my purposes, a hard file (stored on the filesystem) won’t work. I need my solution to be DB-driven. Given that CSS data is referenced from HTML page output either (a) inline or (b) via a LINK file reference, that makes a sort of out-of-phase problem that I need to work on.

First: I suppose the <LINK> mechanism will only work through a reference to a dynamic page. Example:

<link rel=”stylesheet” href=”/css-dyn/mycss.aspx?site=123456″></link>

The “mycss.aspx” page would then create text/css MIME-type content and return it to the sender.

Second: the inline mechanism is potentially simpler, but less modular, and maybe avoids some hidden “gotchas” with the <LINK> method. Just output a <style type=”text/css”> section inside the <head> section of the page to be displayed.

More ideas to come…

Advertisements

0 Responses to “Dynamic CSS”



  1. Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s





%d bloggers like this: