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).

  • Avoid non-standard tags. Their support across browsers is notoriously spotty.

  • Be aware that most valid DOCTYPE declarations will make IE and Firefox go into standards mode. If you're relying on old quirky behavior, you may be disappointed (see page 41).

  • If accented characters or special symbols are not displaying properly, see Chapter 21, Symbols and Non-English Characters.

Figure 22.2. Can you see where the problem is? I've misspelled src. I can't tell you how many times I've torn apart a table or some other complicated construction only to find a miserable little typo like this.

Figure 22.3. The corrected version shows the src attribute spelled correctly, plus I've removed the final / that is used only in XHTML, not HTML.

HTML, XHTML, & CSS(c) Visual QuickStart Guide
HTML, XHTML, and CSS, Sixth Edition
ISBN: 0321430840
EAN: 2147483647
Year: 2004
Pages: 340

Similar book on Amazon © 2008-2017.
If you may any questions please contact us: