0

Hello SO,

I´m working with some complicated list structures, that need to be converted to HTML. Here is my problem:

The ordered lists do have fixed list-item values like this:

1. ...
2. ...
2a. ...
2b. ....

So my first idea was, to use the HTML-List-Elements "value" property. Like:

<ul>
    <li value="2">...</li>
    <li value="2a">...</li>
</ul>

But, as List-Element-Value only takes numbers it will print:

2. ...
2. ...

Is there any way to get the desired result within an <ol>-Element? Or do I have to create my own "list" with float and margins?

EDIT: To make things clear - I can not edit or reformat these list, as they are laws. For an example have a look on: https://www.gesetze-im-internet.de/stgb/__5.html

I can not simply use a nested element in this, as this is not the way the law is written.

Edit 2: The best thing I came up with by now is to give my <li> elements an attribute like data-li-value="2a." and in my css do something like:

[data-li-value]::before {
    content: attr(data-li-value) " ";
    float: left;
    margin-right: 2rem;
    margin-right: .5rem;
    margin-left: -.5rem;
}

While removing the default-list-style-type from the li element...

Thanks for any idea and help! :)

errorinpersona
  • 380
  • 5
  • 17
  • Hey...you see this link https://developer.mozilla.org/en-US/docs/Web/CSS/list-style-type @errori – Anshu Jun 15 '19 at 12:45
  • I think this should answer your question: https://stackoverflow.com/questions/10405945/html-ordered-list-1-1-1-2-nested-counters-and-scope-not-working, basically you need to use a list for 1, 2 and so on, with a nested list, inside of the second `
  • ` element (the 2) to create 2.1, 2.2 etc.
  • – David Thomas Jun 15 '19 at 12:46
  • Thanks for the links. I know these links but they wont help. I updated my question to clarify the issue. – errorinpersona Jun 15 '19 at 12:54