Solved

How to Control List  <LI> position verticle and horizontal

Posted on 2004-08-05
2
1,251 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Column Spacing 3 37
FTP File permissions 1 31
what style is causing the padding 3 25
Bootstrap 3 and Angular 2 12 25
Unordered lists (HTML ul tags) are very handy to create menus of all types, shapes and sizes.  All it takes is a little knowledge of CSS and the possibilities are endless. First off, you should know the general format for menus created using the …
As a result of several questions about how to use Bootstrap I thought it would be a good idea to write down the development aspect of creating a Bootstrapped website in as little time as possible. Part 1 of this article will only concentrate on g…
In this tutorial viewers will learn how add a full-size background image to a webpage using CSS3. Create a new HTML document with an internal stylesheet.: In CSS, define the html element to have a background image. Use a high resolution image.: In t…
In this tutorial viewers will learn how to style a decorative dropcap for the first letter in a paragraph using CSS. In CSS, create a new paragraph class by typing "p.fancy": Then, to style only the first letter of the first sentence, include the ps…

762 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

20 Experts available now in Live!

Get 1:1 Help Now