Web Design Best Practices, XHTML

Recode for XHTML

The best way to start coding a new website is to make a rough sketch on paper. Draw the content blocks, make short notes on the XHTML and CSS you’ll need and try to anticipate the problems you’ll encounter. It’s highly unlikely that you’ll solve all, or even most, problems by this rough sketch, but creating it forces you to think logically and to define the rough outlines of your code. You’ll also find that sketching helps you to remember your fundamental decisions and the reasons behind them better than just starting to write code.

Then create the XHTML file. If you’ve never used XHTML before, your first step should be to ditch some ancient HTML preconceptions. Fortunately migrating from HTML to XHTML is extremely simple:

  • Make all your tags lower case (<p> instead of <P>);
  • Close all your tags, even empty ones (<br /> and <hr /> instead of<BR> and <HR>);
  • Make all attribute names lower case and quote all attribute values; for example, <td colspan=”2″> instead of <TD COLSPAN=2>, and onmouseover instead of onMouseOver;
  • Give empty attributes a value such as <input type=”checkbox” checked=”checked” /> instead of <INPUT TYPE=checkbox CHECKED>;
  • Nest all your tags correctly.

Doctype

Now your HTML has become XHTML. This is not enough, though. By choosing a DOCTYPE you have committed yourself to the Strict, Transitional or Frameset flavor, and you should make sure that you only use the tags and attributes that your chosen flavor allows.

Dreamweaver

When you think you’re ready, validate your pages. You may use Dreamweaver to validate and convert your code by selecting File > Convert > then the specific doctype you want. 

Even when your XHTML is perfectly valid it can contain bad coding. You have to avoid a few practices that, though not expressly forbidden, are strongly discouraged.

Links

This entry was posted in Web Design Best Practices. Bookmark the permalink. Follow any comments here with the RSS feed for this post. Post a comment or leave a trackback: Trackback URL.

Post a Comment

Your email is never published nor shared. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">