How to define a custom name for <li> element in HTML?

unfa

I want to define an ordered list, that looks like this:

3. Foo
   1. Foo
   2. Bar
3a. Bar

I already know I can use

<ol start=3></ol>

markup to skip items 1 and 2, but I don't know how can I make the last element use "3a" as it's name, without nesting another list like this: "3. a. Bar".

Is this even possible in HTML?

ketan

You can do like:

HTML:

<ol>
  <li>One</li>
  <li>Two</li>
  <li class="newList">Three</li>
  <li>Four</li>
 </ol>

CSS:

ol {
    counter-reset: item;
    margin-left: 0;
    padding-left: 0;
}
li {
    display: block;
    margin-bottom: .5em;
    margin-left: 2em;
}

.newList:before{
 content: counter(item) "a " ;
}

li:before {
    display: inline-block;
    content: counter(item) ;
    counter-increment: item;
    width: 2em;
    margin-left: -2em;
}

Check Fiddle

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How to define a custom li element with respect to accessability requirements?

How to define a custom element method with angular elements

ReactJS: Show custom element name in html

How to get the right Xpath for the <li> HTML element?

How to define custom html tags in ckeditor

How to define an empty custom HTML tag?

html input create li element how to set an id for the element

How append li element inside a ul lists with the same class name?

How to define a custom name for delegate method in Rails 5?

Uncaught DOMException: Failed to execute 'define' on 'CustomElementRegistry': "[object HTMLElement]" is not a valid custom element name

How to create a custom HTML li dot with correct indent

How to create html element <li> tag inside <ul>

How to create a custom HTML element with Ace Editor?

How to create a custom HTML element using javascript?

How to add custom style to a HTML element in ejs?

how to get html element by name in jquery?

How to define []= and at() = for a custom collection?

How to define name for slug?

LI element underline is not removing in html

How to get the id value of an html <li> element added to an html <ul> element using prepend() method in jQuery ?

How to update id and name of html element inside div element?

How to best append element name to each HTML element?

How to add name of element to custom javax validation message

Bootstrap 3 custom li element with div designing

Vanilla Custom Element repeater for <option>, <li>, <td>

Google fonts: Define custom name in CSS

XSD define element by name or alternate attribute

Custom HTML element extending another custom element

How to generate the same class name for UL element under LI using JavaScript?