Monday, March 21, 2005

standard rant

So I've been working on cleaning up the code for this site; so many little things have been patched together that odd things are starting to happen in some browsers. I have two conflicting goals: I want to make the site compliant with XHTML and CSS standards, but I also need to hack the fuck out of the code to make it work in Internet Explorer. I occasionally consider just making the thing work correctly, and instead of serving special code to make it work in IE (which is what almost all sites do) just wrapping the whole code in an 'if not IE' block and presenting IE users with a blank page. It's fucking pathetic how many terabytes of IE-specific hacks are served up every day. IE isn't a browser, it's a virus.

When setting out to rewrite the code for this site, I first did what any respectable code writer would do: I went to a bunch of other sites to see how they did it. The results were interesting:
No DOCTYPE, and doesn't validate as anything between HTML 2.0 and XHTML 1.1. One line of javascript, 2 lines of CSS, looks almost identical with both turned off.

XHTML 1.0 DOCTYPE, but does not validate, 90 errors. Looks like a shopping list with CSS turned off.

Boing Boing
HTML 4.01 Transitional DOCTYPE, doesn't validate, 224 errors. Strangly their CSS validates depite having an incorrect parse tree. Appearance essentially unchanged with CSS off.

Validates as XHTML 1.0 Transitional. CSS almosts validates, 2 errors and one warning. Code contains many IE-specific hacks.

HTML 4.0 Transitional DOCTYPE, doesn't validate, 184 errors. Looks like Wired with CSS turned off.
XHTML 1.0 Transitional, doesn't validate, 687 errors. Interestingly, turning off CSS reveals a note saying the site will look much better in a standards-compliant browser. Andy is the only civilian on this list; I chose his site because it is clean and informative without being ugly, not because I wanted to diss his code.

No DOCTYPE specified, doesn't validate as anything. Code is a mashup; XML namespace but HTML 3.2 body tags.

This digital Mecca of nerddom, the place to go for cutting-edge tech news, has an HTML 3.2 Final DOCTYPE, but their server checks specifically for the W3 Markup Validation service and returns a 403 error. I saved a copy of the page and tried to validate it that way, but there are characters on the page that are not UTF-8 encoded and the validator dies. Pay no attention to the man behind the curtain... but there are rumors on the internets that Slashdot is being upgraded to XHTML and CSS compliance.

I think you get the point... all this talk about web standards, XHTML XML CSS DOM DHTML AJAX WTF OMG, and nobody is using them. Why? Because they want their web pages to work for as many people as possible, and adding 10 lines of bells and whistles adds 30 lines of hacks for IE and NS4. I can understand (but not sympathize) why people use IE, but surely anyone using NS4 or IE4 or IE5Mac must be pretty accustomed by now to having the web look like ass. But people who see an ugly site tend to assume the site is buggy rather than question the tools they are using, so site developers continue to accomodate dinosaur/defective browsers.

This problem isn't going away anytime soon... Microsoft has announced that IE7 won't fully support CSS2. It's a chicken-and-egg thing - MS says CSS2 has problems, and it does: specifically, the effectiveness of CSS2 has been crippled by IE's refusal to follow the standard. Perhaps if a large number of sites started serving up "I'm sorry, but your browser sucks... no web for you" messages instead of hacking around the problem, people would get a clue. But then again any plan that relies on a large number of people getting a clue is doomed to fail from the start.

There's another layer of abstraction specific to Blogger sites: Blogger injects code into your page as it is served up, and that code doesn't validate. The changes to make it do so are trivial, but requests to have those changes made are met with a form letter saying "if it isn't too horribly broken, we're not going to touch it". I guess you get what you pay for - or less.