HTML Tutorial

  • 15-Feb-2020
  • 159

Lists

HTML provides a way to create both an ordered list (with elements counting up, 1, 2, 3...) and an unordered list with bullets instead of numbers. Lists are a good way to formalize a list of items and let the HTML styling do the work for you.

Ordered lists

Here is an example of how to create an ordered list:

Lists


HTML provides a way to create both an ordered list (with elements counting up, 1, 2, 3...) and an unordered list with bullets instead of numbers. Lists are a good way to formalize a list of items and let the HTML styling do the work for you.

Ordered lists

Here is an example of how to create an ordered list:

<p>Here is a list of ordered items:p>
<ol>
    <li>First itemli>
    <li>Second itemli>
    <li>Third itemli>
ol>

Ordered lists have a "type" attribute which defines the numbering convention to use.

To count using numbers, use type="1":

<p>Here is a list of ordered items:p>
<ol type="1">
    <li>First itemli>
    <li>Second itemli>
    <li>Third itemli>
ol>

To count using uppercase letters, use type="A":

<p>Here is a list of ordered items:p>
<ol type="A">
    <li>First itemli>
    <li>Second itemli>
    <li>Third itemli>
ol>

To count using lowercase letters, use type="a":

<p>Here is a list of ordered items:p>
<ol type="a">
    <li>First itemli>
    <li>Second itemli>
    <li>Third itemli>
ol>

To count using uppercase roman numerals, use type="I":

<p>Here is a list of ordered items:p>
<ol type="I">
    <li>First itemli>
    <li>Second itemli>
    <li>Third itemli>
ol>

To count using lowercase roman numerals, use type="i":

<p>Here is a list of ordered items:p>
<ol type="i">
    <li>First itemli>
    <li>Second itemli>
    <li>Third itemli>
ol>

Unordered lists

Here is an example of how to create an unordered list:

<p>Here is a list of unordered items:p>    
<ul>
    <li>First itemli>
    <li>Second itemli>
    <li>Third itemli>
ul>

To change the list style attributes, we can use the CSS attribute called list-style-type. The available types are:

  • disc
  • circle
  • square
  • none

Here is an example of the disc list style type:

<p>Here is a list of unordered items:p>    
<ul style="list-style-type: disc">
    <li>First itemli>
    <li>Second itemli>
    <li>Third itemli>
ul>

Here is an example of the circle list style type:

<p>Here is a list of unordered items:p>    
<ul style="list-style-type: circle">
    <li>First itemli>
    <li>Second itemli>
    <li>Third itemli>
ul>

Here is an example of the square list style type:

<p>Here is a list of unordered items:p>    
<ul style="list-style-type: square">
    <li>First itemli>
    <li>Second itemli>
    <li>Third itemli>
ul>

Here is an example of the none list style type:

<p>Here is a list of unordered items:p>    
<ul style="list-style-type: none">
    <li>First itemli>
    <li>Second itemli>
    <li>Third itemli>
ul>

Lists

HTML provides a way to create both an ordered list (with elements counting up, 1, 2, 3...) and an unordered list with bullets instead of numbers. Lists are a good way to formalize a list of items and let the HTML styling do the work for you.

Ordered lists

Here is an example of how to create an ordered list:

The basic elements of an HTML page are:
  • A text header, denoted using the <h1>, <h2>, <h3>, <h4>, <h5>, <h6> tags.
  • A paragraph, denoted using the <p> tag.
  • A horizontal ruler, denoted using the <hr> tag.
  • A link, denoted using the <a> (anchor) tag.
  • A list, denoted using the <ul> (unordered list), <ol> (ordered list) and <li> (list element) tags.
  • An image, denoted using the <img> tag
  • A divider, denoted using the <div> tag
  • A text span, denoted using the <span> tag