HTML
HTML introduction
HTML basics
HTML text format 1
HTML text format 2
HTML text format 3
HTML links
HTML images
HTML image maps
HTML forms
Fieldset/legend tags
Email links
HTML labels
HTML tables
HTML frames
HTML backgrounds
HTML colors
HTML color shades
HTML color usage
HTML marquees
HTML fonts
HTML entities
HTML stylesheets
HTML layout
HTML div/span
HTML audio
HTML video
HTML objects
HTML d'load media
HTML meta tags
HTML scripts
HTML declarations
HTML head section
HTML document types
HTML tag rules
HTML things to avoid
URL formatting
Encoding and decoding
HTML use/access
HTML publish work
History of HTML
HTML summary

Programming

Programming intro
Java

Markup

First webpage guide
XHTML

Style & Layout

CSS

Browser scripting

Javascript
VBScript
AJAX

Server scripting

PHP
ASP

Making money online

Make money online

HTML text formatting (part 1)

Text in an HTML document can be formatted in many ways such as changing the texts size, color, and font type, as well as advanced formatting such as creating lists, paragraphs, and line breaks.

As text formatting in HTML is a huge topic with alot of possibilities, we have written three text formatting lessons. This is the first lesson of those three.

You can skip to the Text formatting part 2 lesson or the Text formatting part 3 lesson right away though it is recommended to read the text formatting lessons in order.

This lesson focuses on:

The <font> tag

The <font> tag is used to set text size, font type, and color. It takes three attributes - size, face, color.

Attributes of the <font> tag
  • size - This attribute is a numerical value specifying the size of the text.

  • face - This attribute specifies the font of the text. It could be any value which is the name of a font on the users computer including Times New Roman, Comic Sans MS, and Courier New.

  • color - This attribute specifies the color of the text.

Example:

<font face="Comic Sans MS" color="green" size="4"> The font of this text will be Comic Sans MS, it will be green, and a size of 4. </font>

Output:

The font of this text will be Comic Sans MS, it will be green, and a size of 4.

NOTE: The <font> tag is deprecated in HTML 4.01 and above

Bold, italic, and underlined text

The <b> tag makes text bold, the <i> tag makes text italic, and the <u> tag underlines text.

Example:

<b>here is some bold text</b> <br /> <i>here is some italic text</i> <br /> <u>here is some underlined text</u> <br /> <u><i><b> here is some bold, italic, and underlined text </b></i></u>

Output:

here is some bold text
here is some italic text
here is some underlined text
here is some bold, italic, and underlined text

Headings

Headings can be displayed using the <h1> through <h6> tags.

NOTE: The lower the number in a heading tag, the bigger the heading.

Heading tags

Example:

<h5>this text is small</h5> <h3>this text is bigger</h3> <h1>this text is the biggest</h1>

Output:

this text is small

this text is bigger

this text is the biggest

NOTE: Headings should NOT be used to simply display text in a certain size. Headings should be used to present the logical order of a document. The way the pages on this website are built is an example of this -- we have the title of the lesson in an <h1> level heading, and the title for each part of the lesson in an <h2> level heading.

Big and small text

You can display big text using the <big> tag and small text using the <small> tag.

The <big> tag will display text as only a little bigger than its regular size, and the <small> tag will display text as only a little smaller than its regular size.

Example:

Here is some <big>big text</big> <br /><br /> Here is some <small>small text</small>

Output:

Here is some big text Here is some small text

Centering text

You can center text (as well as other elements) using the <center> tag.

Example:

<center> This text will be centered </center>

Output:

This text will be centered

NOTE: The <center> tag is deprecated in HTML 4.01 and above.

Abbreviations and acronyms

Abbreviations

Abbreviations are specified with the <abbr> tag. This tag is used to display the value of data which is abbreviated. The <abbr> tag contains a 'title' attribute that sets what the data is an abbreviation of.

Example:

<abbr title="Introduction">Intro.</abbr>

Output:

Intro.

Move your mouse over 'Intro.' to find out what it is an abbreviation of. A small yellow box (called a tooltip) with the abbreviation should appear right next to the word.

Acronyms

Acronyms are specified with the <acronym> tag. This tag works similarly to the <abbr> tag but is used to display the value of data which is displayed as an acronym. The <acronym> tag contains a 'title' attribute that sets what the data is an acronym of.

Example:

<acronym title="Beginners All Purpose Symbolic Instruction Code">BASIC</acronym>

Output:

BASIC

Move your mouse over 'BASIC' to find out what it is an acronym of. A small yellow box (called a tooltip) should appear with the acronym right next to the word.

Addresses

Addresses are placed on a webpage with the <address> tag.

Example:

<address> Mickey Mouse P.O. BOX 12345 Disneyland, USA </address>

Output:

Mickey Mouse P.O. BOX 12345 Disneyland, USA

Computer output tags

Computer output tags are used to display text as computer programming code.

Computer output tags:

Example:

<code> This tag displays computer programming code </code> <br /> <kbd> This tag displays input from the keyboard </kbd> <br /> <tt> This tag displays teletype text </tt> <br /> <samp> This tag displays sample text </samp> <br /> <var> This tag displays variables </var>

Output:

This tag displays computer programming code
This tag displays input from the keyboard
This tag displays teletype text
This tag displays sample text
This tag displays variables

Practice

Online code editor
Practical examples
Practical exercises
Step-by-step tutorials

Reference

Terms glossary
Reference material

Rate this site

Rate this site
Visitor comments