Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make indentation in html ul li tag

I have unordered list which has bulleted text within. I need to indent the list items in line. However for long running text, the style is not working as expected. I should make it aligned within the border box. Here is the css code

ul{
    background-color: #FFFFFF;
    border: 1px solid black;
    border-radius: 3px 3px 3px 3px;
    list-style: disc inside none;
    padding: 10px;
}

Here is the example HTML

<div style="padding:20px">
    <ul>
        <li>Should be minimum of 8 characters</li>
        <li>A long running text A long running text A long running text A long running text A long running text</li>
        <li>Should have at least one number</li>
    </ul>
</div>

enter image description here

JS Fiddle link : http://jsfiddle.net/jHJXq/

like image 815
bragboy Avatar asked Feb 07 '12 19:02

bragboy


People also ask

How do you indent a UL in HTML?

Like an ordered list element, an unordered list element (<ul>) will indent its list items — or bullet points — by default. If you'd like to change the indentation distance, then you can use the margin-left or padding-left property.

How do I indent an unordered list?

Right-click, and then click Adjust List Indents. Change the distance of the bullet indent from the margin by clicking the arrows in the Bullet position box, or change the distance between the bullet and the text by clicking the arrows in the Text indent box.

How do you indent all lines in HTML?

Use margin-left if you want the entire paragraph to be shifted to the right. If you want the entire paragraph to be shifted over, not just the first line, then you can use the margin-left property.

Does HTML has indentation?

No. HTML code does not need to be indented, and all browsers and search engines ignore indentation and extra spacing. However, for any human reader, it's a good idea to indent your text because it makes the code easier to scan and read.


2 Answers

Is this what you are looking for? http://jsfiddle.net/jHJXq/3/

ul{
    background-color: #FFFFFF;
    border: 1px solid black;
    border-radius: 3px 3px 3px 3px;
    list-style: disc outside none;
    padding: 10px 10px 10px 25px;
}

I changed the list style to "outside" and gave some extra padding to the left.

enter image description here

like image 175
IMI Avatar answered Oct 18 '22 01:10

IMI


Add style to the LI:

li {
   margin-left:15px;  
}
like image 7
Diodeus - James MacFarlane Avatar answered Oct 18 '22 03:10

Diodeus - James MacFarlane