How to create an ordered list in HTML5?
To create an ordered list in HTML5, use the
- and <li> tags, 1. Use
- to define the ordered list, and use <li> to represent each item internally. 2. You can specify the starting number through the start property, 3. Set the number type such as numerals, letters or Roman numerals through the type property. 4. It is recommended to use the list-style-type of CSS or a custom counter to achieve more flexible style control to separate structures and styles.
Creating an ordered list in HTML5 is simple. You only need to use the <ol></ol>
tag and then nest the <li>
tag to represent each item. It will be numbered by default, but the numbering style can also be modified through CSS.

Create basic ordered lists using <ol></ol>
and <li>
Ordered lists are defined using the <ol></ol>
(abbreviation of ordered list) tag, and each list item is wrapped with <li>
(list item). for example:
<ol> <li>Step 1: Prepare the materials</li> <li>Step 2: Mix raw materials</li> <li>Step 3: Baking and forming</li> </ol>
The list written in this way will be automatically added with a number and will be incremented from 1. This is the most basic and common usage.

If you want the number to start with a specific number, you can add the start
attribute:
<ol start="5"> <li>Step 5: Check the finished product</li> <li>Step 6: Package and shipment</li> </ol>
This will start with 5.

Set numbering type through type
attribute
By default, ordered lists use Arabic numerals (1, 2, 3...), but you can also change the numbering style via type
attribute:
- <li>
type="1"
: number (default)<li> type="a"
: lowercase English letters<li> type="A"
: capital letters<li> type="i"
: lowercase Roman numeral<li> type="I"
: capital Roman numeralFor example:
<ol type="A"> <li>Option A</li> <li>Option B</li> <li>Option C</li> </ol>
The display effects are A, B, and C.
It should be noted that type
attribute is still valid in HTML5, but in some modern development practices, it is recommended to use CSS to control numbering styles because this can better separate structures and styles.
Use CSS to control numbering styles (more flexible)
Although HTML provides type
attributes, if you need more complex numbering styles, such as bracketed numbers (1., 2., 3.), or custom prefixes, it is recommended to use list-style-type
attribute of CSS.
For example:
<ol style="list-style-type: lower-roman;"> <li>Item 1</li> <li>Item 2</li> <li>Item 3</li> </ol>
This can be displayed as i, ii, iii.
You can also implement more advanced styles in combination with custom CSS counters, such as:
ol { counter-reset: my-counter; list-style: none; } ol li::before { counter-increment: my-counter; content: ""th" counter(my-counter) "step:"; }
In this way, the formats such as "Step 1" and "Step 2" will be displayed before each list item.
Basically that's it. Creating an ordered list is not complicated in itself, but you need to choose the appropriate method according to the scene, such as whether semantics are required, whether style customization is required, etc.
The above is the detailed content of How to create an ordered list in HTML5?. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undress AI Tool
Undress images for free

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Theelementshouldbeusedforcontenttangentiallyrelatedtothemaincontent,suchassidebars,pullquotes,definitions,advertisements,orrelatedlinks;2.Itcanbeplacedinsideoroutsideanarticledependingoncontext;3.ItisasemanticelementthatenhancesaccessibilityandSEObyp

To create a simple HTML5 web page, you need to first use the declaration document type, and then build a basic structure containing, and, which sets the character encoding, viewport and title, add visible content such as title, paragraph, link, pictures and lists. Save it as a .html file and open it directly in the browser for viewing, without server support. This is the basis of a complete and effective HTML5 page.

ThedraggableattributeinHTML5specifieswhetheranelementcanbedragged,withvalues"true","false",oranemptystring(sameas"true").2.Settingdraggable="true"enablesdrag-and-dropforanyelement,butJavaScripteventlistenerslik

To create a custom checkbox, you must first use an HTML structure with label to ensure accessibility; 2. Hide the default checkbox through CSS but retain its functionality; 3. Use pseudo-elements and pseudo-classes to draw the selected state on the custom .checkmark elements; 4. Add hover, focus and select styles to enhance interactive feedback; 5. Keep native inputs present to support keyboard navigation and screen readers, and ultimately achieve beautiful and accessible custom checkboxes.

Theautofocusattributeautomaticallyfocusesaformelementwhenapageloads.2.Itisabooleanattribute,sonovalueisneeded—justincludeautofocusinthetag.3.Onlyoneelementperpageshoulduseittoavoidunpredictablebehavior.4.Itworksoninput,textarea,select,andbuttonelemen

ThetaginHTML5isusedtodefineasectionofmajornavigationlinks,providingsemanticstructureandimprovingaccessibilityandSEO;itshouldwrapprimarynavigationelementslikemenusortablesofcontents,noteverylinkonapage,andcanbeenhancedwithARIAlabelssuchasaria-label=&q

AdefinitionlistinHTML5iscreatedusingtheelementtogroupterms()withtheirdefinitions(),allowingmultipletermstoshareadefinitionoratermtohavemultipledefinitions,makingitidealforFAQs,glossaries,metadata,andcontactdetailswhileimprovingaccessibilityandSEOthro

To effectively improve page loading performance, you need to inline the critical CSS first and load the non-critical CSS asynchronously; 1. Use tools or manually identify the critical CSS and inline it to; 2. Use rel="preload" to combine onload, JavaScript dynamic loading or requestIdleCallback asynchronously; 3. Use media attributes to delay loading of conditional styles such as print or topics; 4. Merge and compress non-critical CSS to reduce requests; you can use the media="print" technique to achieve JavaScript-free asynchronous loading, thereby significantly optimizing the first-screen rendering speed.
