Solved

double ul and li

Posted on 2014-04-19
1
196 Views
Last Modified: 2014-04-19
This is what I want to accomplish:

- 1st item
   - 1st subitem
-second item

When I did the code below, the 1st subitem is indented very far on the inside How do I fix it? Thx
<ul><li>first item </li>
        <ul></li>first subitem</li></ul>
        <li>second item </li>
</ul
0
Comment
Question by:leblanc
1 Comment
 
LVL 52

Accepted Solution

by:
Scott Fell,  EE MVE earned 500 total points
ID: 40010454
First of all, your html is wrong.
1) Everything should be closed in the same order it is opened.
2) Nest your sub inside the li
<ul>
    <li>first item 
        <ul>
            <li>first subitem</li>
        </ul>
    </li>
   <li>second item </li>
</ul>

Open in new window

If you want to control the margin of the sub li, you can add css
li li{margin-left:-20px;}

Open in new window

All together
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>JS Bin</title>
  <style>
    li li{margin-left:-20px;}
    
    </style>
</head>
<body>
<ul>
    <li>first item 
        <ul>
            <li>first subitem</li>
        </ul>
    </li>
   <li>second item </li>
</ul>
</body>
</html>

Open in new window

And working sample http://jsbin.com/regeq/1/
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Developer portfolios can be a bit of an enigma—how do you present yourself to employers without burying them in lines of code?  A modern portfolio is more than just work samples, it’s also a statement of how you work.
Color can increase conversions, create feelings of warmth or even incite people to get behind a cause. If you want your website to really impact site visitors, then it is vital to consider the impact color has on them.
This video teaches users how to migrate an existing Wordpress website to a new domain.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

821 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