Refactoring stylesheets

There is no good way I know of refactoring selector-driven stylesheets. Procedural styling, such as that used by smarty or even vanilla PHP, is easy. Styling starts in one place and flows in a controlled way through to the end. Selectors make life difficult because you don't know what is going to match where or what is overridden by a different selector elsewhere. It's very difficult to work out how it works, even with comments, because you don't know which comments are immediately relevant and besides, they refer to a document structure which is dynamically generated.

I've never managed to cleanly refactor CSS and I've not really tried with XSL, because it looks difficult for all the same reasons. With XSL there's an intermediate XML structure that can be refactored, but this is generated procedurally. But for the presentation layer - CSS, XSL and to some extent Javascript - if anyone knows a better way of refactoring than throwing it all out and starting again, please let me know.


Comments powered by Disqus