I'm new to HTML, CSS and JavaScript, so this may be a very basic problem, however, I haven't been able to find a solution by searching. Most solutions I've found deal with automatically numbered lists, or un-ordered lists.
I'm using Javascript to populate a list on a webpage from a JSON document. The output HTML list looks like this:
<article>
<div>
<ul class='foo'><li class='num'>1.</li><li class='txt'>bar</li></ul>
<ul class='foo'><li class='num'>2.</li><li class='txt'>foo</li></ul>
<ul class='foo'><li class='num'>2a.</li><li class='txt'>very long test here so that it moves to a new line on the webpage</li></ul>
<ul class='foo'><li class='num'>5.</li><li class='txt'>bar</li></ul>
<ul class='foo'><li class='num'>6.</li><li class='txt'>foo</li></ul>
</div>
</article>
I then use CSS to style these to look like a single list:
.foo li{
display: inline;
padding-left: 20px;
}
This shows the generated numbers with the text to the right, however, if the text is long, like in the third ul in the example above, it loses all indentation when it moves down to a new line. Also, if one number is longer than another, the text to the right of it is indented by the same amount extra, but I'd like to have each line of text start in line with the text above and below it.
I've tried floating each list left and right, but that wrecked the formatting I had on the page. I'm sure there's some simple way to overcome this, but any search I've made has been related to automatically generated numbers for ol objects.
How do I keep my own list numbering, but control the consistency of indentation over multiple lines?