CodeBetter.Com
CodeBetter.Com
RSS 2.0 via Feedburner
           Do you Twitter? Follow us @CodeBetter

Jeffrey Palermo [MVP]

Software management consultant and CTO, Headspring Systems

Use XHTML for your web applications, please! - level 100

I realize that a lot of web applications are targeted for IE, and it may be an intranet application.  Even so, it pays to put the line:

<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

Adding this will save you so much grief later on.   First, your CSS will actually cascade down to child elements, so you can have a very clean stylesheet.  Second, you know that your site will render properly in all browsers.  No need to test all the browsers.  By making your pages XHTML, you are adhering to the standard, so that's all you need to worry about. 

The alternative is to muck up your stylesheet with duplicate declarations and the same css class on nested elements.  Then, when the site looks good, just open it in another standards-based browser and cry.

Many people don't know that if you fail to put a doctype at the top of a page, IE will interpret it as HTML4.0.  If you want HTML4.0, then at least put the doctype there:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
   "http://www.w3.org/TR/html4/strict.dtd">
Even then, the other browsers (that default to XHTML) will see the doctype and interpret it as HTML4.

 

I wonder how many web application developers out there have never read the standards docs for xhtml or css. . .



Comments

Thomas Bandt said:

"No need to test all the browsers", not at all true.

For example Firefox and IE act different relating to rendering spacings defined in the style sheet.

All things considered it is how Gareth writes, you have tu do at first all for firefox or opera, and then correct the result for the IE.

Regards from Nuremberg, Germany ;-)
# February 19, 2005 9:01 PM

Eric Newton said:

" wonder how many web application developers out there have never read the standards docs for xhtml or css. . . "

I haven't and I even know why they're there. ...Vs.Net template change ;-)
# February 20, 2005 11:01 AM

Jeffrey Palermo said:

The last time I checked, I thought VS.NET 2003 didn't support XHTML.
# May 19, 2005 9:30 AM

Jeffrey Palermo said:

Guy,
You are correct, and that is being fixed with VS 2005, but most of the markup is still generated by us, and I have the decision of what DOCTYPE to use.
# May 19, 2005 10:30 AM

Jeffrey Palermo said:

I originally was going to label this post level 200, but given how few people know about Html standards,...
# July 29, 2005 11:45 AM

About Jeffrey Palermo

Jeffrey Palermo is a software management consultant and the CTO of Headspring Systems in Austin, TX. Jeffrey specializes in Agile coaching and helps companies double the productivity of software teams. Jeffrey is an MCSD.Net , Microsoft MVP, Certified Scrummaster, Austin .Net User Group leader, AgileAustin board member, INETA speaker, INETA Membership Mentor, Christian, husband, father, motorcyclist, Eagle Scout, U.S. Army Veteran, and Texas A&M University graduate. Check out Devlicio.us!

This Blog

Syndication