| Home Web | Top Bottom | Contents Prev Next |
Some Inline Tags
Examples of Inline Tags
<em> and <strong> vs. <i> and <b>
Placement of Inline Tags
Example
You've already seen two inline tags: <i> and <b>. Now we'll take a look at a few more of these.
<big> Increase font size <small> Decrease font size <em> Emphasis <strong> Strong emphasis <u> Underline (deprecated)
<big>This is larger <big>and this is even larger.</big></big>
<small>This is smaller <small>and this is even smaller.</small></small>
<em>This is emphasized</em>.
<strong>This is strongly emphasized</strong>.
<u>This is underlined</u>.
Most browsers display <em> as italics and <strong> as bold. They differ from <i> and <b> in that <i> and <b> specifically mean to use italics and bold, while <em> and <strong> are left up to the browser (or "user agent") to interpret in any way that makes sense.
The choice of <em> and <strong> versus <i> and <b> is important when you consider aural (speaking) browsers. <em> and <strong> cause voice emphasis, while <i> and <b> are ignored. So use <em> and <strong> when you feel that voice emphasis is useful, and <i> and <b> when you feel it is not. Try reading your text aloud with and without emphasis to see which is most appropriate. You'll probably find that most frequently voice emphasis is not desirable, and that <i> and <b> are the best choices.
Inline tags are allowed pretty much anywhere text is allowed. You can use them inside most block tags, and you can nest inline tags inside other inline tags.
You cannot place block tags inside inline tags. The following code is NOT valid:
<i> <p> A paragraph </p> </i>
This code is not valid HTML, and the validator will report it as an error. Browsers are more forgiving, however, and will generally display this code the way it's intended, in italics. If you look at code on many web sites especially code that was written for version 3 and older browsers you'll probably spot a lot of misplaced tags such as this. The <font> tag in particular is an inline tag that was frequently abused in this manner. The <font> tag provides an HTML method for specifying font size, color and face, so a <font> tag can be fairly lengthy. Web page coders frequently want to use a particular font size and face for most of the page, and it was much easier to place a <font> tag right after the <body> tag and to close it right before the </body> tag. This usually works, but it has never been a valid use of the <font> tag.
Here's your chance to play with inline tags a little bit. Notice that the code here is not valid: there's a <p> tag inside an <i> tag. Be sure to try validating this code so that you'll recognize the messages that the validator produces for this error. It's an error you'll probably make frequently until you become more familiar with HTML.
| Home Web | Top Bottom | Contents Prev Next |