Solved

How to Control List  <LI> position verticle and horizontal

Posted on 2004-08-05
2
1,252 Views
Last Modified: 2009-02-23
How do you control the horizontal position (spacing) of <li> in a css? I don't like the default spacing, it indents way too much for my taste! Also is there a way to control the verticle spacing from the top and bottom  of the list?? By this I mean the space before and after the <ul> & </ul>
0
Comment
Question by:894359
2 Comments
 
LVL 3

Expert Comment

by:hyperslug
ID: 11728386
Use CSS:

<style>
      ul { margin: 0px; }
      li { margin-left: -20px; }
</style>
<ul>
      <li>item</li>
      <li>item</li>
      <li>item</li>
</ul>
0
 
LVL 31

Accepted Solution

by:
seanpowell earned 500 total points
ID: 11728611
Hmmm - that will probably throw the list outside the browser window in IE.

Also, you need both margin and padding on the list item to accomodate Moz browsers, etc.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title></title>
<style type="text/css">

ul
{
      padding:0;
      margin:0;
      border:1px solid black;
}

li
{
      margin-left:15px;
      padding-left:15px;
}

</style>
</head>
<body>

<ul>
    <li>text</li>
    <li>text</li>
    <li>text</li>
</ul>

</body>
</html>

For more info:
http://www.washington.edu/webinfo/snippets/css/lists.html
http://www.w3schools.com/css/css_list.asp

Thanks,
Sean
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
HTML and CSS for a complex page 20 61
jQuery CSS Scroll Issue 3 73
Can't get the PDF Icon to appear on the webpage 1 21
.php tree directory? 5 56
"I want to put my photos online, but I don't want them stolen.  What settings should I use?" When You Put Photos Online First and foremost, any digital file published on the WWW can be copied, stored, modified, retransmitted, etc.  Remember Naps…
This article discusses four methods for overlaying images in a container on a web page
In this tutorial viewers will learn how to define a gradient in CSS. Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Gradient. Define the background as "linear-gradient(to right, #ee3668, black)". Ensure you …
In this tutorial viewers will learn how to position overlapping items using z-index in CSS. They will also learn the restrictions on the z-index property.  Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Red.…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now