Select Page

The ordered list, ol tag, in HTML5


An ordered list can be numerical or alphabetical. Typically, <ol> is rendered as a numbered list.


nanadwumor

May 19, 2023

HTML5 - ordered list tag


  • <ol> tag in html is used to list items in order
  • start attribute of <ol> defines where marker value should sart
  • type attribute of <ol> defines the type of marker to use, whether 1,23..,ab,c,…, i,ii,iii,…etc
  • reversed attribute reverses numbering of the marker

RECOMMENDED ARTICLES


Difference Between Absolute and Relative References in HTML
Difference Between Absolute and Relative References in HTML

A relative reference does not specify the complete path to a web page. It specifies only the name of the web page. An absolute reference or url contains all the information necessary to locate a resource or target A relative reference does not...

Block And Inline Level Tags in HTML
Block And Inline Level Tags in HTML

Block elements start on a new line and end with a carriage return. That's, immediately after ending on a horizontal space, next block element goes to nest line. A block level element is like a container. It can contain other elements. Examples of...

Selecting a browser for HTML5 development
Selecting a browser for HTML5 development

Google's Chrome browser is simple to use and has the most up-to-date HTML5 features making it easier for developers. It also has pretty good developer tools. We recommend you use this browser to learn HTML5 Chrome Firefox Opera Apple Safari...


The <ol> tag in html is used to list items in order. ol is short for ordered list

Unlike the <ul> tag, the <ol> tag is recommended if items are to be listed in a particular order.

An ordered list can be numerical or alphabetical. Typically, <ol> is rendered as a numbered list.

Syntax


Join Other Subscribers on Our YouTube Channel and Don’t Miss a thing!


For example,

Output

HTML - </p>
<ol> tag output

Attributes of <ol> tag

start

The <ol> tag has an attribute called start. This attribute allows you to specify which value the numbering should begin from. For example, we can let our list above to start number from 13 instead of the default 1.

Output

HTML - </p>
<ol> tag start at 13 number

type

The type attribute specifies the marker to use. That’s, whether to use 1,2,3 or a,b,c or A,B,C or i, ii, iii or I, II, III  etc

Output

HTML - </p>
<ol> tag type attribute

Example 2:

Output

HTML - </p>
<ol> tag type attribute Example 2

Example 3:

Output

HTML -</p>
<ol> tag type attribute Example 3

Example 4:

Output

HTML - </p>
<ol> tag type attribute Example 4

reversed

As the name suggests, the reversed attribute reverses the numbering pattern.

That’s, the list items are rendered in reverse order, from the highest number to the lowest.

For example, if the items in the list are 6, they are numbered in descending order as 6,5,4,3,2,1.

You don’t need to specify any value for the reversed attribute. If you specify any value, it will be neglected.This is because HMTL must count the number of items automatically and start numbering in reverse order. This is to avoid any conflict in the event you happen to give a wrong value. For example, if you happen to give, say 4, to a list that is more than or less than 4.

HTML - </p>
<ol> tag reversed attribute

You don’t need to specify any value for the reversed attribute. If you specify any value, it will be neglected. This is because HMTL must count the number of items automatically and start numbering in reverse order. This is to avoid any conflict in the event you happen to give a wrong value.

For example, if you happen to give say 6, to a list that has just four items, it will be an error. In the example below, reversed is assigned the value 6 for a list that contains only four items. It is evident that the value 6 is ignored and the reverse numbering is automatically done correctly.

Output

HTML - </p>
<ol> tag reversed attribute

You can create a list of ordered or unordered links by nesting the <a> tag within the <ol> or <ul> tag respectively.


You May Also Like…




0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *