?
Solved

double ul and li

Posted on 2014-04-19
1
Medium Priority
?
202 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 54

Accepted Solution

by:
Scott Fell,  EE MVE earned 2000 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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

Originally, this post was published on Monitis Blog, you can check it here . Websites are getting bigger and more complicated by the day. Video, images and custom fonts are all great for showcasing your product or service. But the price to pay in…
Australian government abolished Visa 457 earlier this April and this article describes how this decision might affect Australian IT scene and IT experts.
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

864 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