Anaganaga

Stories about technology and magic.

Styling without CSS

Posted on | December 22, 2009 | No Comments

Well, not quite. The idea is to get rid of static CSS files and have the styling in a JavaScript file, in the form of JSON. Defining the styles using JavaScript is quite powerful and flexible as well, especially when combined with a good selector engine like jQuery. JSON stylesheets explains the benefits of using JavaScript for styling. There are some downsides to that approach as well.

  • It will not work when JavaScript is turned off. The fallback should be a CSS file that comes close to what the JSON stylesheet does. Maybe some tool can create the CSS file from the JSON stylesheet automatically.
  • If you are using an editor like Dreamweaver, auto complete features do not work with CSS written as JSON objects. Again, there can be a tool that takes in CSS (which can be created easily with your favourite editor) and creates the JSON stylesheet which can be used to add additional logic or complexity.

Is it really necessary to push styles onto JavaScript? Imagine a photo blogging template that changes its theme depending on the photo being displayed (I believe such themes already exist). Such a theme can be easily implemented using JSON stylesheets. We just need more tools around this idea for us to start using it instead of plain old CSS.

Comments

Leave a Reply





Subscribe to my feed

About

I work as a technologist in an investment bank. I code for fun, I code for a living and I code for change.

Search