Menu
HTML Text Tags Basics

Today, most webpage text design is accomplished through the use of style definitions rather than html tags. Although style definitions are extremely powerful for text design, they are also very complicated. For example, through the principle of cascading a designer may loose track of exactly where a text style was defined. However, html text definitions are always with the text that they apply to.

Text on a webpage should always be placed inside a container. The container may be a table cell or an html span or div element, but the most commonly used container for text is a paragraph, which is designated by the <p> and </p> tags.

In pure html the font would be defined using the <font> tag. The W3C (World Wide Web Consortium) does not recommend using the font tag because it's "deprecated". Deprecated means at some point in the future it will no longer be supported by Web browsers. However, I believe because the Web contains millions of old webpages that use the font tag, and thousands of new webpages are being created each day using the font tag, it will be supported long into the future.

<p><font face="Verdana" color="red" size="3">Red Verdana text in size 3</font></p>

Red Verdana text in size 3

Shown above is an example of use of the font tag. It defines the Verdana font in the color red and in the size 3. Font size can be a value from 1 to 7.

<p style="font-family:verdana; font-size:16px; color:red">Red Verdana text 16 pixels in size.</p>

Red Verdana text 16 pixels in size.

If you want to heed the "deprecated" warning, shown above is an example of the same text without the font tag, the text being defined by the style attribute of the paragraph tag.

Using HTML Tags to Format Text

You can also use style to define text boldness, italics, and underline. However, defining these attributes with html requires less code and is easier to remember and easier to debug.

Simply place the <b> tag before and the </b> after any text you want to appear bold. Place the <i> tag before and the </i> after any text you want to appear italic. Place the <u> tag before and the </u> after any text you want to appear underlined.

I do not recommend using the html underline tag because Web users tend to mistake underlined text for links. They'll be clicking on our underlined text and think you have a bad link. I also want to point out that using the styles text-decoration property you can define overline and line-through along with underline.

Using HTML Tags to Make Text Bold

Shown below is an example of use of the html bold text tag.

<p>This text is normal <b>this text is bold</b> this text is normal.</p>

This text is normal this text is bold this text is normal.

The <strong> tag does exactly the same thing. I first ran into the strong tag being used by Microsoft FrontPage. In my opinion it's a totally unnecessary tag.

<strong>Defines strong text</strong>

Defines strong text

Using HTML Tags to Make Text Italic

Shown below is an example of use of the html italic text tag.

<p>This text is normal <i>this text is italic</i> this text is normal.</p>

This text is normal this text is italic this text is normal.

The <em> tag does exactly the same thing. I first ran into the em tag being used by Microsoft FrontPage. In my opinion it's a totally unnecessary tag.

<em>Defines emphasized text</em>

Defines emphasized text

Using HTML Tags to Underline Text

Shown below is an example of use of the html underline text tag.

This text is normal <u>this text is underlined</u> this text is normal.

This text is normal this text is underlined this text is normal.

Using HTML Tags to Make Teletype Text

Shown below is an example of use of the html teletype text tag, which produces monospaced text.

This text is normal <tt>this text is monospaced</tt> this text is normal.

This text is normal this text is monospaced this text is normal.

teletype text simulates text created by the old mechanical teletype machine. It's often used to indicate computer code, keyboard text, or text returned by a computer.

Using HTML Tags to Make Text Smaller or Bigger

Html also has a set of tags that make text smaller and bigger. This allows you to increase or decrease the font size without explicitly using a font tag or style attribute.

<small>Defines small text</small> Regular text <big>Defines big text</big>

Defines small text Regular text Defines big text

Using HTML Tags to Make Headings and Subheadings

Html provides a set of heading tags that allow you set the size of the text in your headings and subheadings. The size ranges from <h1> to <h7>. Shown below is examples of the use of the html heading tags.

<h1>Heading Size 1</h1>

Heading Size 1

<h2>Heading Size 2</h2>

Heading Size 2

<h3>Heading Size 3</h3>

Heading Size 3

I personally do not use the heading tags. Instead I always use a style attribute with the font-size property to set text size for my headers. However the heading tags do have the advantage that they contain embedded line returns, in other words, they're block elements. Also, some people claim that search engines look for heading tags and give the text within them higher relevance.

Using HTML Tags to Preserve Formatting

Writing lots of articles containing code, one html tag that I find very useful is the <pre> (pre-format) tag. To format text contained between a <pre> and a </pre> tag, the Web browser uses the formatting contained within the text. This means you can display complicated formatting without using paragraph and line break tags.

<pre>
This is an example
of
pre-formatted text 
</pre>
This is an example
of
pre-formatted text 

Although today most webpage text design is accomplished through the use of style definitions rather than html tags. I find some of the old html tags are quicker to use, require less code, and are easier to understand.


Learn more at amazon.com

More HTML Code:
• Nesting HTML Lists
• Easy Code to Add Yahoo Site Search to Your Website
• Setting the Number of Items Visible in a Select List
• HTML center Tag
• What is HTML?
• Set Form Controls Tab Order With tabindex Attribute
• Create a Meta Tag Slide Show - No Java Script Required
• Divide a Table Into Head (thead), Body (tbody), and Footer (tfoot) Sections
• HTML5 Header Element
• The Font Tag