|MySQL Conference and Expo April 14-17, 2008, Santa Clara, CA|
After you create a default stylesheet, just copy it and use it as a template for additional style sheets, or themes. Store all style sheet files in a single common folder. To import a style sheet into an HTML document after creation, you write:
To make this reusable, you have to consider two points. First, of course, you have to wrap it in a function (see
It's very important to use absolute paths -- paths that are evaluated starting from your document root folder. This is necessary because you'll have to adjust the path every time you insert the script into a new document which has a different relative location to your style sheet files -- which isn't really a reusable script solution. When you look at the code line above, you'll also find the variable
Next we need a method to let users choose between different styles, so we create a reusable function called
While the document is reloaded
4. Step: Add the script and correct settings
After you create the snippet with the correct (absolute) paths, you can just cut and paste it anywhere in your site's documents.
As we saw, implementing your own themes is easy as long as you understand the underlying principles and technologies. Also, keep in mind, that CSS support is not as consistent as it should be. For sites with a large audience, you should stick to the old dirty way. While we didn't discuss all the complexities in this article, hopefully, you've become curious for more -- and that's really all I wanted. Stay tuned!