The <ol> HTML element represents an ordered list of items, typically rendered as a numbered list.
Instantiate the Ol class using Ol::widget().
$ol = Ol::widget();Use the provided methods to set specific attributes for the a element.
// setting class attribute
$ol->class('external');Or, use the attributes method to set multiple attributes at once.
$ol->attributes(['class' => 'external', 'title' => 'External Link']);If you want to include content within the ol tag, use the content method.
$ol->content('MyContent');Generate the HTML output using the render method.
$html = $ol->render();Or, use the magic __toString method.
$html = (string) $ol;Below are examples of common use cases:
// adding multiple attributes
$ol->class('external')->content('MyContent')->title('MyTitle');// setting the `start` attribute
$ol->start(5);// setting the `reversed` attribute
$ol->reversed();// setting the `type` attribute
$ol->type('A');Explore additional methods for setting various attributes such as lang, tabindex, title, value and more.
Refer to the Attribute Tests for comprehensive examples.
The following methods are available for setting attributes:
| Method | Description |
|---|---|
attributes() |
Set multiple attributes at once. |
class() |
Set the class attribute. |
content() |
Set the content within the ol element. |
id() |
Set the id attribute. |
lang() |
Set the lang attribute. |
name() |
Set the name attribute. |
reversed() |
Set the reversed attribute. |
start() |
Set the start attribute. |
style() |
Set the style attribute. |
tabindex() |
Set the tabindex attribute. |
title() |
Set the title attribute. |
type() |
Set the type attribute. |
value() |
Set the value attribute. |
Refer to the Custom Method Test for comprehensive examples.
The following methods are available for customizing the HTML output:
| Method | Description |
|---|---|
render() |
Generates the HTML output. |
widget() |
Instantiates the Ol::class. |