View video tutorial

HTML reversed Attribute

HTML

The reverse attribute in HTML is a boolean attribute used with the <ol> (ordered list) element to display the items in the list in descending order.

Definition and Usage


➔ Its main use is to display the contents of the <ol> tag in reverse order.

➔ In HTML, simply add it to the opening <ol reversed> tag, but in XHTML, it must be defined as <ol reversed="reversed">.

Syntax
//In HTML
<ol reversed id="sample">
    <li>First item</li>
    <li>Second item</li>
    <li>Third item</li>
</ol>

//In Javascript
let element=document.querySelector("#sample");
element.reversed = true;
//or
element.setAttribute("reversed", "");
// or
element.setAttribute("reversed", "reversed"); // required for XHTML

Applies to

This attribute can be used on the following element.

Attribute Element
reversed <ol>