United Blogs

Welcome to United Blogs Sign in | Join | Help
in Search

James Musson's blog

CSS and XHTML

For years now one of my main jobs has been persuading people to separate their business logic code from their presentation code in their applications. It's really a no brainer as far as I am concerned, but it constantly amazes me how many applications I see where the developers and designers seem to have been unable to achieve this even at a fairly simple level. Now I come from a middle tier background; I am not particularly good with UI technologies. That is I know the theory but my UIs still always look like crap. For that reason, I guess, I don't tend to get too involved in what I would consider to be the 'far-left' of the diagram (as I always draw it!), i.e. the pure presentation technology. A question I am often asked is how to create 'skinnable' sites with ASP.NET. My normal answer to this is to use a combination of CSS and user (or web) controls to create a site that can be presented in many different ways. Another common way to achieve this is to use an XML/XSL framework and this enables you to 'simply' deploy a new set of XSL stylesheets for a new look/layout. I say simply in inverted commas because in my experience XSL development is not necessarily straightforward (mainly due to the lack of tool support, ease of debugging etc). This approach can often lead to performance issues as well unless you are pretty careful about designing your XPath selectors and stylesheet caching strategy.

Anyway as I mentioned earlier, I am not always on top of the latest UI related standards and XHTML kind of passed me by (actually more acurately I couldn't really be bothered to check it out until now). Well I have looked at it now and I like what I have seen so far. Firstly it removes one of my biggest gripes with HTML and that is that it is not generally well formed and this leads to sloppy code. XHTML even specifies that for a document to be valid all elements and attributes must be in lower case. Good - not only does this make the HTML cleaner, but it also means that I can process an XHTML page with my favourite XML technologies. The thing that surprised me was that the specification actually enforces a separation of document structure and formatting/markup; I wasn't expecting this. This is really good because it means that a document is not valid XHTML if you stick font tags or (b)s or (i)s in it. And this leads nicely onto CSS. CSS is one of those technologies that I have never really got to grips with because I considered it to be the designer's job. Unfortunately this has led me to ignore some of the possibilities it opens up (although to be fair to myself widespread, consistent CSS support hasn't been around for long even if you consider that it is there now). What I really like about the combination of these technologies is that the idea of separating data and structure from presentation is pushed even further up the stack and it becomes much easier to write your presentation components to simply worry about producing structured output and then have the formatting taken care of afterwards.

So I am going to redesign this blog to be pure, valid XHTML and CSS with no table based layout (which is bad for accessibility because complex table structures confuse screen readers) over the next few weeks. I guess I should point out that .Text (or at least the skin I have applied) makes reasonable use of CSS already, but I want to go further. I have made a start by creating a simple static XHTML stripped down page (also available in xml format) that I have validated with the W3C's validator (as you can see by the natty new logo at the bottom of it!) Watch this space for my journey through the world of design with XHTML and CSS...

Published Tuesday, April 20, 2004 2:30 PM by james

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

No Comments

Leave a Comment

(required) 
(optional)
(required) 
Submit
Powered by Community Server, by Telligent Systems