HTML Element: <ol>
[this page | pdf | back links]
The HTML <ol> element indicates an ordered
list. The list can be numerical or alphabetical. Individual items within the
list are identified using <li>
elements. Lists can be styled using CSS.
The attributes it can take
(other than HTML
global attributes and HTML event attributes)
include:
Attribute
|
Description
|
More
|
reversed
|
List order should be
descending (3, 2, 1) not ascending (1, 2, 3)
|
Here
|
start
|
Start value of an
ordered list
|
Here
|
type
|
Type of element
|
Here
|
It used to support the compact attribute, but this is no
longer supported by HTML 5.
To create or access such an element in JavaScript
see here. The
corresponding HTML DOM
object supports standard
DOM properties and methods, and additional properties with the same name and
meaning as the attributes of the underlying HTML element referred to above. The
default style applicable to this element is shown here.
EXAMPLE:
HTML USED IN THIS EXAMPLE:
<!DOCTYPE html>
<html> <!-- Copyright (c) Nematrian Limited 2018 -->
<head></head>
<body>
Created using HTML:<br>
<ol>
<li>Apple</li>
<li>Banana</li>
</ol>
<br><br>Created using JavaScript:<br>
<span id="element"></span>
<script>
var y = document.getElementById("element");
var x = document.createElement("OL");
var x1 = document.createElement("LI");
var x2 = document.createElement("LI");
var txt1 = document.createTextNode("Apple");
var txt2 = document.createTextNode("Banana");
x1.appendChild(txt1);
x2.appendChild(txt2);
x.appendChild(x1);
x.appendChild(x2);
y.appendChild(x);
</script>
</body>
</html>
|
NAVIGATION LINKS
Contents | Prev | Next | HTML Elements