Character Formatting

 
HTML has two types of styles for individual words or sentences: logical and physical. Logical style tags indicate the meaning of the text, while physical style tags mark the specific appearance of a section of text. For example, in the preceding sentence, the words "logical style" were tagged as "emphasis" and the words "physical style" were tagged as "bold". The same effect (formatting those words in italics) could have been achieved via a different tag that tells your browser to "put these words in italics".

 

Logical Versus Physical Style Tags

If physical and logical style tags produce the same result on the screen, why are there both?

In the ideal SGML universe, content is divorced from presentation. Thus SGML tags a level-one heading as a level-one heading, but does not specify that the level-one heading should be, for instance, 24-point bold Times centered. The advantage of this logical style approach (it's similar in concept to style sheets in many word processors) is that if you decide to change level-one headings to be 20-point left-justified Helvetica, all you have to do is change the definition of the level-one heading in your Web browser. Indeed, many browsers today let you define how you want the various HTML tags rendered on-screen using what are called cascading style sheets, or CSS.

Another advantage of logical style tags is that they help enforce consistency in your documents. It's easier to tag something as <H1> than to remember that level-one headings are 24-point bold Times centered or whatever. For example, consider the <STRONG> tag. Most browsers render it in bold text. However, it is possible that a reader would prefer that these sections be displayed in red instead. (This is possible using a local cascading style sheet on the reader's own computer.) Logical styles offer this flexibility.

Of course, if you want something to be displayed in italics (for example) and do not want a browser's setting to display it differently, you should use physical styles. Physical styles, therefore, offer consistency in that something you tag a certain way will always be displayed that way for readers of your document.

Try to be consistent about which type of style tags you use. If you tag with physical styles, do so throughout a document. If you use logical styles, stick with them within a document. Keep in mind that future releases of HTML might not support certain logical styles, which could mean that browsers will not display your logical-style coding. (For example, the <DFN> tag -- short for "definition", and typically displayed in italics -- is not widely supported and will be ignored if the reader's browser does not understand it.)

The main difference between logical and physical style tags is what they say. Logical styles say something about the meaning of the Author's text. Physical styles say how the Author wants to display the text.

 

Logical Style Tags

Tag Purpose Example
<ABBR> abbreviation: indicates that content is an abbreviation. Typically does not change how the text is displayed in the browser. <abbr title="abbreviation">abbv</abbr>
abbv
<ACRONYM> acronym: indicates that content is an acronym. Typically does not change how the text is displayed in the browser. <acronym title="World Wide Web">WWW</acronym>
WWW
<ADDRESS> address: for an address. Typically displayed in italics. <address>15 5<sup>th</sup> Avenue N.W.</address>
15 5th Avenue N.W.
<CITE> cite: for titles of books, films, etc. Typically displayed in italics. <cite>HTML for the World Wide Web <font size="-1">Fourth Edition</font></cite>
HTML for the World Wide Web Fourth Edition
<CODE> code: for computer code. Displayed in a fixed-width font. <code>The &lt;stdio.h&gt; header file</code>
The <stdio.h> header file
<DEL> deleted: for text that has been deleted. Allows revision control in HTML documents. Not widely supported. The last word has been <del>deleted</del>.
The last word has been deleted.
<DFN> definition: for a word being defined. Typically displayed in italics. <dfn>NCSA Mosaic is a World Wide Web browser.</dfn>
NCSA Mosaic is a World Wide Web browser.
<EM> emphasis: for emphasis. Typically displayed in italics. <em>Consultants can reset your password if you call the help line.</em>
Consultants can reset your password if you call the help line.
<INS> inserted: for text that has been inserted. Allows revision control in HTML documents. Not widely supported. The last word has been <ins>inserted</ins>.
The last word has been inserted.
<KBD> keyboard: for user keyboard entry. Typically displayed in plain fixed-width font. <kbd>Enter passwd to change your password.</kbd>
Enter passwd to change your password.
<Q> quotation: for a short quote. Typically displayed in plain fixed-width font with surrounding quotes. <q>To be or not to be.</q>
To be or not to be.
<SAMP> sample: for a sequence of literal characters. Displayed in a fixed-width font. <samp>Segmentation fault: Core dumped.</samp>
Segmentation fault: Core dumped.
<STRIKE> strike-out: for text that has been stricken. Typically displayed with a center line.
This works simply as an <S> tag in some browsers -- like:
<strike>The ruling is in favor of the defendant.</strike>
<s>The ruling is in favor of the plaintiff.</s>

The ruling is in favor of the defendant.
The ruling is in favor of the plaintiff.
<STRONG> strong: for strong emphasis. Typically displayed in bold. <strong>NOTE: Always check your links.</strong>
NOTE: Always check your links.
<VAR> variable: for a variable that is replaced with specific information. Typically displayed in italics. <var>rm filename deletes the file.</var>
rm filename deletes the file.

 

Physical Style Tags

Tag Purpose Example
<B> bold: bold text. <b>Bold text example.</b>
Bold text example.
<BIG> big: big text. This is the same as using a <font size="+1"> tag. <big>Big text example.</big>
Big text example.
<BLINK> blink: blinking text. <blink>Blinking text example.</blink>
Blinking text example.
<FONT> font: font formatting. Font Color, Face, and Size Formatting
<I> italics: italic text. <i>Italics text example.</i>
Italics text example.
<SMALL> small: small text. This is the same as using a <font size="-1"> tag. <small>Small text example.</small>
Small text example.
<SUB> subscript: subscript text. H<sub>2</sub>O
H2O
<SUP> superscript: superscript text. 2<sup>3</sup> = 8
23 = 8
<TT> typewriter: typewriter text (fixed-width font). <tt>Typewriter text example.</tt>
Typewriter text example.
<U> underlined: underlined text. <u>Underlined text example.</u>
Underlined text example.

 

Special Formatting Tags

There are other formatting tags that used for special purposes, are not widely supported, or have been deprecated. If you want to see them, click here.

Combining Styles

Character formatting tags also are sometimes not additive. For example, you might expect that: <B><I>some text</I></B> would produce bold-italic text. On some browsers it does; other browsers interpret only the innermost tag. If you want to see some style combinations, click here.