Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Html ordered list ol, add space between number and text

Tags:

html

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) enter image description here

like image 987
Manoj Shenoy Avatar asked Jan 09 '16 15:01

Manoj Shenoy


People also ask

How do I add a space between an ordered list in HTML?

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.

Is there a way to increase the space between the number and the text of each li >?

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.

How do you style numbers in OL?

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.


2 Answers

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>
like image 198
CoderPi Avatar answered Nov 14 '22 02:11

CoderPi


Note:- You can give the space by this code.

<ol style="padding-left:1em">
  <li style="padding-left:1em">Some text</li>
</ol>
like image 22
Parth Raval Avatar answered Nov 14 '22 00:11

Parth Raval