Text Formatting
It should come as no surprise that a full third of the HTML tags are associated with controlling
the way text is displayed. Using these tags a page designer can exercise full control over the
font and formatting of text.
HTML text formatting tags come in two flavors - those that specify the exact font attribute
desired (font formatting) and those that specify how the text content will be modified relative to the rest of
the page content (logical formatting).
In both cases the technique is the same - all text found between a tag pair will be displayed according to
the rules of the tag pair.
Return to top of document
Font Formatting
The following font formatting tags are defined in the HTML 4.01 specification. To use them, simple place
the text to be formatted between the tag pairs. One tag pair can be nested between another
to apply more than one attribute to the enclose text (such as bold-italicized text).
| Tag | Description | Example
|
|---|
| <b>: | bold | The results are in!
| | <font>: | font | (see example below)
| | <i>: | italics | The results are in!
| | <s>: | strikeout | The results are in!
| | <strike>: | strikeout | The results are in!
| <u>: | underline | The results are in!
| | <tt>: | teletype | The results are in!
| | <sub>: | subscript | The results are in!
| | <sup>: | superscript | The results are in!
| |
Remember to put both the start and end tags around any text that you want to exhibit the results of these tags.
If you only put the start tag and leave off the end tag, the tag will take effect all the way to the end of the document.
Of these tags, only the <font> tag supports three attributes. They are listed in the table below
along with an example of their effects.
| Attribute | Code Example | Results of Code
|
|---|
| color | <font color=red> Hello</font> | Hello
|
|---|
| face | <font face=Courier> Hello</font> | Hello
|
|---|
| size | <font size=+2>Hello</font> | Hello
|
|---|
The size attribute may be assigned an absolute point size or a relative point size (as in the example above).
The color attribute may be assigned one of the pre-named or RGB colors. The
face attribute may be one or more font family names, enclosed in quotes. If more than one is entered, the browser
users the first one that it comes to which is available on the operating system.
Additionally HTML supports a <basefont> tag that supports the same attributes as the <font> tag.
The attributes take effect from the point at which the <basefont> tag is entered in the HTML document,
so to affect the entire document place the tag in the document header.
The <basefont> tag may be used muliple times and modifies all subsequent text in the HTML document.
Here's an example of the tag:
<basefont face=Courier size=12 color=blue></basefont>
If this code is placed in the document header, the entire document would use the Courier font, blue color and font-size of 12 points
The <basefont> tag pair is unique in that the content of the affected text is not within the tag pair.
Return to top of document
Logical Formatting
The following HTML tags are rendered by the browser with respect to the basefont of the web page
document. Except for the <h1> - <h6> tags most of these do not see that much use.
Most browsers display these in one of just a few ways: italics, bold, or monospace (all characters the
same width). And, since the HTML specification doesn't specify the exact display type, different
browsers may renders each of these tags differently so authors tend to use tags that assure them of
how the display will appear.
| Tag | Description | Example
| | <big>: | big | The results are in!
| | <h1>: | headers (h1-h6) | The results are in!
| | <em>: | emphasis | The results are in!
| | <strong>: | strong | The results are in!
| | <ins>: | inserted | The results are in!
| | <del>: | deleted | The results are in!
| | <cite>: | citation | The results are in!
| | <address>: | address | The results are in!
| | <samp>: | sample | The results are in!
| | <small>: | small | The results are in!
| | <code>: | code | The results are in!
| | <kbd>: | keyboard | The results are in!
| | <var>: | variable | The results are in!
| | <dfn>: | definition | The results are in!
|
Remember to put both the start and end tags around any text that you want to exhibit the results of these tags.
If you only put the start tag and leave off the end tag, the tag will take effect all the way to the end of the document.
|