Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add new HTML tip about ordered lists
- Loading branch information
1 parent
a6e13e3
commit d57c3db
Showing
1 changed file
with
39 additions
and
0 deletions.
There are no files selected for viewing
39 changes: 39 additions & 0 deletions
39
content/snippets/html/s/start-ordered-list-at-different-number.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
--- | ||
title: Start your ordered HTML lists at a different number | ||
shortTitle: Ordered lists starting number | ||
type: tip | ||
language: html | ||
tags: [content] | ||
cover: neon-desk-1 | ||
excerpt: Did you know you can customize the starting number of your ordered lists? Learn how with this quick tip. | ||
dateModified: 2024-05-10 | ||
--- | ||
|
||
Ordered lists in HTML start at the number `1` by default. But did you know you can customize the starting number of your ordered lists? This might feel like an uncommon need, yet I'm sure I've had a use for it at some point in the past. | ||
|
||
A lesser-known attribute of the `<ol>` tag is the `start` attribute. This attribute allows you to specify the **number at which the list should start**. | ||
|
||
```html | ||
<ol start="4"> | ||
<li>Lorem</li> | ||
<li>Ipsum</li> | ||
<li> | ||
<ol start="12"> | ||
<li>Dolor</li> | ||
<li>Sit</li> | ||
</ol> | ||
</li> | ||
<li>Amet</li> | ||
<li>Consectetur</li> | ||
</ol> | ||
``` | ||
|
||
```css | ||
ol ol { | ||
list-style-type: lower-roman; | ||
} | ||
``` | ||
|
||
https://codepen.io/chalarangelo/pen/GRaRqmZ | ||
|
||
As you can see, you can use it for ordered lists, as well as **nested order lists**. It even works with every `list-style-type` you can think of, including **Roman numerals** and **alphabetic characters**. |