.NET & It's !DOCTYPE: A Poor First Impression
Thursday December 02nd 2004
I've been given the exciting opportunity to learn a bit of .NET, but the start has been a bit rocky. Here's the welcoming mat Microsoft offered:
For one thing, forget about a tableless page with .NET. Out of the box .NET defaults to outputing all of its code within nested tables. I've read that it might be possible to eventually change this, but it would require digging into all of it's template files, which is simply not an option right now (and probably not for most developers, considering the amount of time it would take). Strike One.
Still, I knew that .NET at least used stylesheets (often inline) to style page elements, so before digging into the programming side of things I set out to whip up a basic, global stylesheet (just styling the normal elements like body, h1, h2, h3, p, form, etc.). All's well at this point, my mocked-up html works perfectly fine with the valid CSS.
But when I put my stylesheet into our first .NET page, things looked off. Some of my styles took, but others didn't. And then I remembered having this issue about two years ago when I was working with a .NET developer as his designer. Back then it took us a good couple of hours to track the problem down to the page's !DOCTYPE. While .NET may insert a !DOCTYPE tag, at HTML 4.0 Transitional, it's incomplete, and thus useless. The result is that IE defaults to quirksmode.
In quirksmode, it turns out that if you assign certain styles to the body element, like font styles, they are not cascaded down into table cells. So if you want your styles to work you must also style your TDs. Either that or alter every single cotton-picking !DOCTYPE, which isn't exactly what I would call reasonable. As a third option we could also dig into the program's HTML template pages, but for security reasons (we're working at a client off-site) we don't have access to our Program Files directory, so that's out as well.
Strike Two. *sigh* It is difficult in times like these to not shake your fist at the Microsoft Gods in an exhausted, weakened battle cry, and ask mercy for just one break. Just one, people!