In this installment of Back To Basics I wanted to talk about HTML as we know it, or don't know it. Browsing around sites developed in ASP.NET I couldn't help noticing that most developers don't even code proper HTML. Why is ASP.NET development plagued with this? Let's analyze.
Numerous times I did View Source on .NET sites and noticed chunks of meaningless HTML right in the header.
<HEAD>
<title>versioninformation</title>
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name=vs_defaultClientScript content="JavaScript">
<meta name=vs_targetSchema
content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
Looks familiar, anyone? I've already criticized this code and suggested improvements in my April 2004 article Remastering Web Form Templates. Most people don't even bother cleaning up this mess aside from the fact that it's pointless and meaningless on the web.
Looking further I also noticed that only 1 out of 100 developers codes proper HTML. That's pretty disturbing. Just when you thought you were proficient at it, open up an HTML 4.x spec and read it. It's a sobering experience.
How many .NET developers use samp, var, code, acronym and abbr elements? Whether you like pre better than code is a matter of personal preference, but, in the grand schema of things, they are a proper way to set apart code samples. Or, take quotes for example: anyone using blockquote and q? What's the difference between div and span?
There's no point to recite the spec here, but you get my drift, I hope. There's much more to HTML than <font size="2"> and <td vAlign="top">. There are many ways to express something with much more semantic meaning.
Blame Trail
There are way too many parties to blame for our incompetence. For one, it is the fault of server controls shipped with ASP.NET 1.x! Yes, quite a few of them produce horrendous markup. Most third-party server controls do, too. Standard compliance is nowhere in sight.
We can also blame adaptive rendering. Personally, I stay away from the asp:Panel control because it turns into a table from a div in any browser outside of Internet Explorer. I use asp:PlaceHolder instead. At least, it won't produce any markup anywhere.
We can blame Microsoft for their lack of commitment to standards. Consider SharePoint Server. Yes, you can write custom widgets, but have you seen a clean one yet?
Also, we can blame training companies and MCTs for not even mentioning good HTML practices. How many of them offer training in web standards? How about only CSS? Wintellect? No. New Horizons? No. Extreme Logic? No. DevelopMentor? No. There's plenty of coverage of Indigo, Avalon, Lonhorn, etc—all the funky technologies due in almost two years from now. I challenge trainers to introduce a course or two in web standards. I guarantee: if taught properly people will love them!
Finally, we can blame Microsoft's marketing machine for hyping up betas and technology previews of all kinds, and disregarding what we need here and now. There's little attention, if any, is paid to the current tools. I haven't read a single article on MSND for weeks, neither have I been to an MSDN event or a newsgroup meeting for a few months. With an insane whirlpool of projects at work I can't drag my a## across Long Island and half of Manhattan to listen to yet another presentation on TabletPC, Yukon or Whidbey. None of it helps me get my job done, and, consequently, none of it servers our customers. That's some reality check right there for Microsoft folks, ain't it?
What Is It With Web Standards Compliance?
Why am I tooting this horn? ASP.NET is a powerful framework for web development. As far as I'm concerned, the most powerful to date. Maybe this is exactly what blurs our sight. After all your hardcore HttpModules and HttpHandlers are done processing pipeline events, after all your templated databound controls and triple nested datagrids fired their Render and RenderContens methods, it is HTML that travels back to the user!
Where Do We Start?
How about we start with Roger Johansson's Developing With Web Standards? It's an outstanding head start. How about we learn from mistakes of others made over and over again? How about we start paying attention to DOCTYPEs? A couple of books by prominent designers will sure put you on the right path. In upcoming installments of Back To Basics we'll talk about XHTML, CSS, web form templates and so on.
Conclusion
If Soma got his numbers right, according to Forrester Research 56% of decision makers at large companies in North America indicated that they'd be doing the majority of their development work on .NET this year
. What I think we're missing at this point is a breed of ASP.NET developers who truly, deeply care for the web and are committed to serving it to the best of their ability.
Remember: there's no shame in learning HTML!
Good luck in your endeavors! If y'all need help, advice, consulting services, etc, in this field, please let me know.