I want to add space between number of ordered list and text
ex :
1. Hello.
2. Test.
Space between "1." and "Hello" needs to be increased.
Note: I'm using below style, because i want no. to start with left most
ol
{
word-break: break-all;
}
li
{
list-style-position: inside;
padding: 0;
}
I want exactly like below image, im able to get everything other than the space between numbering of list and text(marked in the image)
To create space between list bullets and text in HTML, use CSS padding property. Left padding padding-left is to be added to <ul> tag list item i.e. <li> tag. Through this, padding gets added, which will create space between list bullets and text in HTML.
Answer. Yes there is a way to do this! We can use CSS to target the <li> elements and then apply some left padding to them. This will nudge the text to the right, away from the numbers.
An ordered list can be numerical or alphabetical. The <li> tag is used to define each list item. Tip: Use CSS to style lists. Tip: For unordered list, use the <ul> tag.
Note that you had .li
instead of li
in your code
ol {
word-break: break-all;
margin: 0;
padding: 0;
}
ol ol {
margin-left: 2em;
}
li {
list-style-position: inside;
padding: 0;
}
li::before {
content: "";
width: 20px;
display: inline-block;
}
<ol>
<li>Hello. Hello. Hello. Hello. Hello. Hello. Hello. Hello. Hello. Hello. Hello. Hello. Hello. Hello. Hello. Hello. Hello. Hello. Hello. Hello. Hello. Hello. Hello. Hello. Hello. Hello. Hello. Hello. Hello. Hello. Hello. Hello. Hello. Hello. Hello. Hello.
Hello. Hello. Hello. Hello. Hello. Hello. Hello. Hello. Hello. Hello. Hello. Hello. Hello. Hello. Hello.</li>
<li>Test.</li>
<ol>
<li>Hello.Hello. Hello. Hello. Hello. Hello. Hello. Hello. Hello. Hello. Hello. Hello. Hello. Hello. Hello. Hello. Hello. Hello. Hello. Hello. Hello.</li>
<li>Test.</li>
</ol>
</ol>
Note:- You can give the space by this code.
<ol style="padding-left:1em">
<li style="padding-left:1em">Some text</li>
</ol>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With