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 2)

This is part 2 of our three lessons on text formatting.

Read the Text formatting part 1 lesson.
Read the Text formatting part 3 lesson.

This lesson focuses on:

Definition lists

A definition list is a list of words together with their definitions organized in a certain manner. Definition lists are created using a few tags.

Definition list tags
  • <dl> - The <dl> tag begins a definition list.

  • <dt> - The <dt> tag begins a definition term.

  • <dd> - The <dd> tag defines the description of a term in a definition list.

Example:

<dl> <dt><b>Cactus<b></dt> <dd>A spikey plant</dd> <dt><b>HTML</b></dt> <dd>A markup language for the web</dd> </dl>

Output:

Cactus
A spikey plant
HTML
A markup language for the web

NOTE: You should bold the terms in a definition list (as in the example above) to set them apart from the definitions. Doing this will present clearly what the terms are and what the definitions are and will avoid confusion.

Deleted and inserted text

Deleted and inserted text is displayed with the <del> and <ins> tags.

Example:

There are <del>5,000</del> <ins>5,280</ins> feet in a mile.

Output:

There are 5,000 5,280 feet in a mile.

Quotations

With HTML, you can display long and short quotations. Long quotations are displayed with the <blockquote> tag. Short quotations are displayed with the <q> tag.

Example:

<blockquote> HTML stands for Hyper Text Markup Language. When you are viewing a webpage, you do not have to look at it in a linear fashion. Instead, you can look at any part of the page anytime you want. Hyper being the opposite of linear is the way HTML operates, allowing you to view any part of a webpage at any time. HTML is a markup language -- a language that has code which indicates layout and styling. Some other markup languages include XML and SGML. </blockquote> <q>HTML is a markup language.</q>

Output:

HTML stands for Hyper Text Markup Language. When you are viewing a webpage, you do not have to look at it in a linear fashion. Instead, you can look at any part of the page anytime you want. Hyper being the opposite of linear is the way HTML operates, allowing you to view any part of a webpage at any time. HTML is a markup language -- a language that has code which indicates layout and styling. Some other markup languages include XML and SGML.
HTML is a markup language.

Superscripts and subscripts

Superscripts

Superscripts are created with the <sup> tag. The <sup> tag stands for Superscript. It is used to set text to a superscript.

Example:

10<sup>2</sup> = 100

Output:

102 = 100

Subcripts are created with the <sub> tag. The <sub> tag stands for Subscript. It is the opposite of <sup> and is used to set text to a subscript.

Example:

H<sub>2</sub>O

Output:

H20

Creating spaces

Browsers ignore anything more than one consecutive space. The solution to this is the &nbsp; character entity. Every time you insert this character entity into your code, it will create one space.

Example:

<i>some text</i>

Output:

some text

while.....

<i>some text</i>

produces this output:

     some text

You can read more about character entities in the HTML text formatting (part 3) lesson or the full lesson on HTML entities.

Lists

Lists are an excellent way to present information in an organized fashion. There are three types of lists which include numbered (ordered) lists, bulleted (unordered) lists, and definition lists (discussed at the beginning of this lesson). Lists begin with the <ul> tag for a bulleted list and the <ol> tag for a numbered list. If you use a list with the <ul> tag, you must end it with a </ul> tag. If you are using a list with the <ol> tag, you must end it with an </ol> tag. The <li> tag is used to insert items into lists.

Bulleted lists

The bulleted list is a list which includes a bullet next to each item in a list.

Example of a bulleted list:

<b>Fruits</b> <ul> <li>Apples</li> <li>Oranges</li> <li>Bananas</li> </ul>

Output:

Fruits
  • Apples
  • Oranges
  • Bananas

If you do not like the default bullets in an unordered list (discs), you can use squares instead by assigning the type attribute the value "square" in the <ul> tag or circles by assigning the type attribute the value "circle" in the <ul> tag.

Example of a bulleted list using square and circle bullets:

<b>Fruits</b> <ul type="square"> <li>Apples</li> <li>Oranges</li> <li>Bananas</li> </ul> <b>Vegetables</b> <ul type="circle"> <li>Lettuce</li> <li>Cucumbers</li> <li>Tomatoes</li> </ul>

Output:

Fruits
  • Apples
  • Oranges
  • Bananas
Vegetables
  • Lettuce
  • Cucumbers
  • Tomatoes

NOTE: The disc bullets appear by default, but you can still specify disc bullets by assigning the type attribute the value "disc" in the <ul> tag.

Example:

<b>Fruits</b> <ul type="disc"> <li>Apples</li> <li>Oranges</li> <li>Bananas</li> </ul>

Output:

Fruits
  • Apples
  • Oranges
  • Bananas

Numbered lists

The numbered list is a list which uses numbers instead of bullets next to each item in a list.

Example of a numbered list using regular numbers:

<b>Computer languages</b> <ol> <li>HTML</li> <li>Javascript</li> <li>PHP</li> </ol>

Output:

Computer languages
  1. HTML
  2. Javascript
  3. PHP

Example of a numbered list using roman numerals:

<b>Computer languages</b> <ol type="I"> <li>HTML</li> <li>Javascript</li> <li>PHP</li> </ol>

Output:

Computer languages
  1. HTML
  2. Javascript
  3. PHP

a numbered list using roman numerals is created by assigning the type attribute in the <ol> tag the value "I"

Lists within lists

It is possible to implement lists within lists. Doing so presents information in a hierarchial fashion, and each level in the list can have a new type of bullet or number, or not.

Example of a list within a list using bullets:

<ul> <li>Big animals <!-- first inner list begins here --> <ul> <li>Giraffe</li> <li>Elephant</li> <li>Bear</li> </ul> <!-- first inner list ends here --> </li> <li>Small animals <!-- second inner list begins here --> <ul> <li>Rabbit</li> <li>Cat</li> <li>Hamster</li> </ul> <-- second inner list ends here --> </li> </ul>

Output:

  • Big animals
    • Giraffe
    • Elephant
    • Bear
  • Small animals
    • Rabbit
    • Cat
    • Hamster

Example of a list within a list using numbers:

<ol> <li>Big animals <!-- first inner list begins here --> <ol> <li>Giraffe</li> <li>Elephant</li> <li>Bear</li> </ol> <!-- first inner list ends here --> </li> <li>Small animals <!-- second inner list begins here --> <ol> <li>Rabbit</li> <li>Cat</li> <li>Hamster</li> </ol> <!-- second inner list ends here --> </li> </ol>

Output:

  1. Big animals
    1. Giraffe
    2. Elephant
    3. Bear
  2. Small animals
    1. Rabbit
    2. Cat
    3. Hamster

Example of a list within a list using bullets and numbers:

<ul> <li>Big animals <!-- first inner list begins here --> <ol type="I"> <li>Giraffe</li> <li>Elephant</li> <li>Bear</li> </ol> <!-- second inner list begins here --> </li> <li>Small animals <!-- second inner list begins here --> <ol type="I"> <li>Rabbit</li> <li>Cat</li> <li>Hamster</li> </ol> <!-- second inner list ends here --> </li> </ul>

Output:

  • Big animals
    1. Giraffe
    2. Elephant
    3. Bear
  • Small animals
    1. Rabbit
    2. Cat
    3. Hamster

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