goer.org | HTML Tutorial : Basic : Font Styles

Table of Contents

About
Introduction
Diving In
Structure
Tinkering
Tags
Attributes
Browser Tools
Basic
Paragraph Breaks
Headings
Font Styles
Colors
Links
Images
Lists
Intermediate
Style Sheets
Classes and IDs
Div and Span
Font Control
Borders
Margins and Padding
Align and Indent
Advanced
Tables
Miscellany
SHTML

Font Styles

The style tags provide a straightforward way to control the font. These tags fall into two categories: physical styles and logical styles. The style tags provide only crude control over your text; for more sophisticated techniques, see the Font Control section.

Physical Styles

Physical style tags allow you to specify a particular font change. For example, to make text bold, you can mark it off with the <b> tag: <b>bold text</b>.

Inline Style Tags

Unlike the <p>aragraph tag and <h>eader tags, the style tags listed above don't mark off a "block" of text -- they perform their work without adding extra line breaks:

<P> vs. <B> (source)

<p>
  1. This is a paragraph with a section of 
  <b>bold text</b> inside of it.
</p>

<b>
  2. This is a section of bold text with 
  <p>a paragraph</p> inside of it.
</b>

The first sentence results in one "block" with a couple of bold words inside of it. In the second sentence, the <p> tags break the text up into multiple blocks.

<P> vs. <B> (Results)

1. This is a paragraph with a section of bold text inside of it.

2. This is a section of bold text with

a paragraph

inside of it.

Logical Styles

At first glance, logical styles seem similar to physical styles:

You might have noticed that the <strong< tag looks an awful lot like the <b> tag, the <em> tag looks a lot like the <i> tag, and so on. However, there is a subtle difference between the physical styles (such as <b> and <i>) and the logical styles (such as <strong> and <em>).

The <i> tag literally means, "italicize this text." The <em> tag literally means, "emphasize this text." What does "emphasized text" mean, exactly?

Most browsers interpret it to mean, "italicize this text." So in practice, <em> usually leads to the same result as <i>. However, there are a couple of points to consider:

In theory, you can muck with the definitions of the physical style tags, but this is bad form. Bold should be bold; changing the definition of the <b> tag doesn't make a lot of sense, if you think about it.