Saddling Up with HTML Horse Sense
People used to refer to common sense as "horse sense." Most things about HTML fall under the realm of horse sense. After you see HTML tags a few times, most of the rules "feel right," and you have little trouble remembering or using them most of the time. You will occasionally make mistakes, though; don't be surprised to see that most of a document's text is in italics because you forgot to add a </i> tag to end italics.
Here are a few basic HTML rules and some "gotchas" to watch out for:
- Most HTML tags work in pairs. (Does that make these dynamic duos "tag teams"?)
- For example, if you want some text to appear in bold, you have to put <b> at the front of the text that you want to have appear in bold, and you have to put </b> at the end of the text. (The slash, /, indicates that a tag is being turned off.) If you forget the </b> at the end, you can easily end up with a document that looks fine at the start but then switches to bold somewhere in the middle — and this bold continues all the way through to the end.
- So remember to use paired tags and to check your document for unpaired tags before you publish it. If you still end up seeing italics or bold all over your document, you know what to look for.
- HTML tags are written in lower case.
- Convention says to put HTML tags in ALL CAPS so that they stand out from the text they're embedded in. However, newer standards specify lower case for HTML tags. Inside an anchor, put the hypertext reference (such as a URL) in the case it normally has (upper or lower) if you're using it elsewhere. The following example illustrates this use of capitalization:
<a href="textver.htm">Text version.</a>
- The parts of the tag that are predefined HTML tags, such as <a>, </a>, and href, are in ALL CAPS. The filename is in all lowercase letters, a convention used by UNIX (a type of operating system) that may save you some problems if your Web page ends up on a UNIX server. You can capitalize the text between the tags, which appears on the Web page as link text, in whatever way makes sense for your Web page's readers.
- UNIX machines are case-sensitive: If you call one file MyFile.txt and another file myfile.txt, they are saved as separate files. The Macintosh and PC are case-insensitive and treat the names MyFile.txt and myfile.txt the same. Because you may end up putting your Web files on a Web server that's a different kind of machine from the one you create them on, you need to pay attention to the use of upper- and lowercase. The easiest rule is the one followed by UNIX users: Always use lowercase letters for filenames. (Some UNIX users go to extremes and use lowercase for everything, including all the text in personal e-mail messages they send.)
- HTML ignores paragraph symbols and tabs in your text.
- One of the most confusing things about HTML is that it ignores the paragraph markers created in your text when you press Enter, as well as tab characters. When displaying HTML, the browser automatically breaks lines to fit the current window size. And the browser makes a paragraph break only when it sees the paragraph tag, <p>, or some other tag that implies the start of a new line (such as a top-level heading tag, <h1>).
- HTML needs you to put paragraph tags (<p>) between paragraphs.
- No matter how many times you hit Return while typing your text, you don't prevent the text from showing up as a big blob on your Web page unless you put paragraph tags (<p>) between paragraphs.
- Basic HTML looks different on different types of browsers.
- Basic HTML doesn't give you much control over the appearance of your document. (Newer versions of HTML allow more control but aren't supported by older versions of popular browsers, so we suggest that you avoid the new stuff.) Different browsers handle the same tags differently. For example, a top-level heading (specified by the <h1> and </h1> tags) may look much larger in one browser than in another browser.
- Some tags don't work on some browsers.
- Some browsers (such as Netscape Navigator) support tags that other browsers can't handle. Stick with basic tags to avoid the chance of giving users nasty surprises when they view your documents.
- Users configure their browsers differently.
- As if the differences among different browser versions weren't enough, users can configure their browsers differently. Users who have bigger monitor screens tend to look at documents in a bigger window. But because these users sit farther back from their big screens — remember your mother telling you always to sit at least six feet from the TV — they may also use larger font sizes to display text. Some users set their browsers to display all graphics as the page transmits; a few turn off graphics. All these idiosyncrasies can make your document look different to different users.