Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to center ordered list number in HTML

I am currently learning HTML programming. I have a problem:

If I put like this:

<html> <body align="middle"> HEADLINE <ol> <li>First Item</li> </ol> </body> </html> 

The problem is the number (1.) is on the left when I wanted it to be aligned under the headline. How can I get the whole list item to the middle?

I need atleast 10 reputation to add pictures so I'll provide a link to another website for you to see the picture: ALIGNING

like image 428
Nikolas Avatar asked Oct 14 '13 16:10

Nikolas


People also ask

How do you right align an ordered list in HTML?

To make a right-aligned version of the list, only three changes need to occur. First, set the "UL" "text-align" to "right". Second, change the left "background-position" from "0" to "100%" - which makes the image align up with the right edge. And finally change "padding-left" to "padding-right".

How do you center an item in HTML?

Center Align Text To just center the text inside an element, use text-align: center; This text is centered.


2 Answers

You are aligning texts in the body.

Try this:

.center {    text-align: center;    list-style-position: inside;  }
<h4 align="center">HEADLINE</h4>  <ol class="center">    <li>First Item</li>  </ol>
like image 142
Nuno Duarte Avatar answered Oct 03 '22 21:10

Nuno Duarte


This is very old post but this this is the solution I did.

CSS:

.center {  text-align: center;  list-style-position: inside; } ol.center li {  text-align: left;  margin-left: 45%; } 

HTML

<ol class="center">Lorem ipsum dolor sit amet consectetur adipisicing elit. Reprehenderit, repellat. <li>List1<li> <li>List2<li> </ol> 

Final Result would look lke this : Output

like image 42
Shomeek Basu Avatar answered Oct 03 '22 20:10

Shomeek Basu