Formatting Text

Most text formatting (such as specifying fonts, font sizes, colors, margins, alignment etc.) should really be done using Cascading Style Sheets (CSS), which we'll cover in a later section. While it is possible to do this directly in your HTML code, you might as well learn to do this the right way from the beginning, so we're not going to cover that method here.

There are some elements which are useful for highlighting certain sub-sections of your text though (although you could also do these things in CSS too).

Bold Text

The <b> and </b> tags are used to identify text which will be highlighted in bold. The <strong> and </strong> tags are used to identify text which is strongly emphasized, which is also highlighted in bold.

<p>This paragraph includes some <b>bold text</b>
and some <strong>strongly emphasized</strong> text.</p>

Some people prefer to use <b>, arguing that it's shorter, simpler and less ambiguous (because <b> obviously means bold, whereas <strong> could mean other things). Other people prefer to use <strong>, arguing that it's more descriptive, and could be presented in other ways (such as in red text) if you so choose (whereas representing <b> as red text doesn't make sense). There tend to be heated debates on forums, but in the end there isn't a definitive answer on which is best, and it probably boils down to a matter of opinion.

One argument in favor of <strong> that's often cited is that screen readers ignore <b> but can put audible emphasis on words if <strong> is used. While this is possible, a test of the two most popular screen readers by The Paciello Group found that they ignore both <b> and <strong>.

Italic Text

The <i> and </i> tags are used to identify text which will be highlighted in italics. The <em> and </em> tags are used to identify text which is emphasized, which is also highlighted in italics. The relative merits of using <i> and <em> are the same as for <b> and <strong> in the previous section.

Subscripts and Superscripts

The <sub> and </sub> tags are used to identify text which will be displayed as subscript. The <sup> and </sup> tags are used to identify text which will be displayed as superscript.

<-- Previous Page

Text

Next Page -->

Line Breaks and Spaces