Tom Morris

13 November 2008

A pungent mix of programming, philosophy, pedanticism, procrastination, perplexity, peripheral political polemic, and platters of preposterousness.

How not to do (X)HTML

I have to point this out: Social Median, in addition to being filled with a whole load of boring ‘social media’ marketing shite has some of the worst markup I’ve ever seen. Let’s count the problems: almost every single element has a style attribute, declaring the same set of values as all the previous elements in the document (hint: it is a stylesheet and it cascades), has a whole bunch of javascript pseudo-protocol and event handler attribute use, and, just in case that isn’t enough bloat, tons more inline scripting and styling and quite a few lines of just empty space. Not to mention my favourite: upper-case SCRIPT elements in an XHTML 1.0 Transitional document. I’m so tempted to make a validator that wouldn’t just give you a boolean yes or no but would give you gradations of how much you suck - I could then use this site for calibration.

Of course, having just been rude about the site, people will now get the wrong idea (laughing at other people’s failure is frowned upon in Web 2.0 land, it’s all about love and conversation and kittens). So I’ll give the moral: it’s not just about snobbery. If your HTML sucks, bad shit happens. The pages take a long time to load. If you take all that JavaScript and CSS and load it off into separate files, your pages will load quicker as the browser will cache them. It also makes them a lot more maintainable. No reason not to. And if your markup is good, there are plenty of places that your content will go that people don’t expect: curses-based text mode browsers like links/lynx, assistive technology, phones, PDAs and other mobile devices, small screens, big screens, Greasemonkey and scraper-writing elite haxors etc.

Not sucking isn’t hard. But you do need to take time out and learn. For those who don’t, give me some time and I’ll have a little script that will codify into percentage terms how much you suck. Maybe.

(Thanks to bentrem on Twitter for the pointer to the markup.)

Tags:

libby has put really good coverage up on the SWIG scratchpad of the SWIG-UK event on Tuesday. Go read it.

Tags:

Looks like, after many years of people telling me I’m crazy for wanting to write teensy, one-paragraph posts without titles, I’m vindicated again. But of course.

Tags: