Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to reduce indentation in CSS Styled UL tags?

Status
Not open for further replies.
Oct 11, 2006
300
US
Hi,

I have built a nested hierachial tree with the un-ordered UL tags.


Code:
<ul id="menu">
  <li>
    <a href="#">TopMgr1</a>
    	<ul>
    		<li><a href="#">Mgr1</a></li>
    			<ul>
    				<li><a href="#">Sub1</a></li>
    				<li><a href="#">Sub2</a></li>
    				<li><a href="#">Sub3</a></li>
    			</ul>
    		<li><a href="#">Mgr2</a></li>
				<ul>
    				<li><a href="#">Sub4</a></li>
    				<li><a href="#">Sub5</a></li>
    			</ul>
    		<li><a href="#">Mgr3</a></li>
    			<ul>
				    <li><a href="#">Sub6</a></li>
    			</ul>
    		<li><a href="#">Sub7</a></li>
    	</ul>
  </li>
</ul>
The CSS style is:


Code:
#menu {
  padding:0;
  margin:0;
  }
#menu li {
  list-style-type:none;
  }
What property can I use to reduce the indentation of the child UL tags under the top tags?

Thanks.
 
try (tested)
Code:
#menu {
  padding: 0;
  margin: 0;
  }
#menu [b]ul {
padding: 0;
margin: 0;[/b]
  list-style-type: none;
  }

Greg
"Personally, I am always ready to learn, although I do not always like being taught." - Winston Churchill
 
Also, your nesting is incorrect. You close the list item element that should have the nested list before you start nesting. The code you have right now will not validate. Try it like this:
Code:
<ul id="menu">
  <li>
    <a href="#">TopMgr1</a>
        <ul>
            <li><a href="#">Mgr1</a>
                <ul>
                    <li><a href="#">Sub1</a></li>
                    <li><a href="#">Sub2</a></li>
                    <li><a href="#">Sub3</a></li>
                </ul>
            </li>
            <li><a href="#">Mgr2</a>
                <ul>
                    <li><a href="#">Sub4</a></li>
                    <li><a href="#">Sub5</a></li>
                </ul>
            </li>
            <li><a href="#">Mgr3</a>
                <ul>
                    <li><a href="#">Sub6</a></li>
                </ul>
            </li>
            <li><a href="#">Sub7</a></li>
        </ul>
    </li>
</ul>
Other than that, follow Greg's advice. And make sure play with both margins and padding on both nested uls and lis.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top