Home

How to Create Ordered Lists for HTML5 and CSS3 Programming

|
|  Updated:  
2016-03-26 13:18:01
HTML5 and CSS3 All-in-One For Dummies
Explore Book
Buy On Amazon

Ordered lists in HTML5 are almost exactly like unordered lists. Ordered lists traditionally have numbers rather than bullets (although you can change this through CSS if you don’t want numbers).

How to view an ordered list

Here is a page with a basic ordered list — basicOL.html.

You can see a list where the items are numbered. When your data is a list of steps or information with some type of numerical values, an ordered list is a good choice.

image0.jpg

How to build the ordered list

The code for basicOL.html is remarkably similar to an unordered list:

<!doctype html>
<html lang="en">
<head>
 <meta charset="UTF-8">
 <title>basicOL.html</title>
</head>
<body>
 <h1>Basic Ordered List</h1>
 <h2 id="tab3" >Top ten dog names in the USA</h2>
 <ol>
  <li>Max</li>
  <li>Jake</li>
  <li>Buddy</li>
  <li>Maggie</li>
  <li>Bear</li>
  <li>Molly</li>
  <li>Bailey</li>
  <li>Shadow</li>
  <li>Sam</li>
  <li>Lady</li>
 </ol>
 <p>
  data from http://www.bowwow.com.au
 </p>
</body>
</html>

The only change is the list tag itself. Rather than the

    tag, the ordered list uses the
      indicator. The list items are the same
    1. pairs used in the unordered list.

      You don't indicate the item number anywhere; it generates automatically based on the position of each item within the list. Therefore, you can change the order of the items, and the numbers are still correct.

      This is where it's great that HTML is about meaning, not layout. If you specified the actual numbers, it'd be a mess to move things around. All that really matters is that the element is inside an ordered list.

      About This Article

      This article is from the book: 

      About the book author:

      Andy Harris earned a degree in Special Education from Indiana University/Purdue University–Indianapolis (IUPUI). He taught young adults with severe disabilities for several years. He also taught himself enough computer programming to support his teaching habit with freelance programming.
      Those were the exciting days when computers started to have hard drives, and some computers connected to each other with arcane protocols. He taught programming in those days because it was fun.
      Eventually, Andy decided to teach computer science full time, and he still teaches at IUPUI. He lectures in the applied computing program and runs the streaming media lab. He also teaches classes in whatever programming language is in demand at the time. He has developed a large number of online video-based courses and international distance education projects.
      Andy has written several books on various computing topics and languages including Java, C#, mobile computing, JavaScript, and PHP/MySQL.
      Andy welcomes comments and suggestions about his books. He can be reached at [email protected].