Checking the Easy Stuff: HTML

Here are some common problems with HTML code. Many of these also apply to XHTML.

To check the easy stuff with HTML:

  • Make sure you’ve spelled everything right. I can’t tell you how many times I write scr instead of src (which stands for source, by the way).

  • Be careful about nesting. If you open <p> and then use <b> make sure the closing </b> comes before the final </p>.

  • The final / in empty XHTML tags is not part of the HTML specification. If you want the file to validate as HTML, you’ll have to get rid of it. (Better yet, switch to XHTML.)

  • Make sure the DOCTYPE matches the HTML you’re actually using. For example, if you want to use deprecated tags, don’t use HTML strict, use HTML transitional (see pages 40 and 56) ...

Get HTML, XHTML, & CSS, Sixth Edition: Visual QuickStart Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.