Jump to content

Lists inside lists!


Cronthenoob

Recommended Posts

I've got something like this :

<ul>  <li>Item 1</li>  <li>Item 2</li>  <li>Item 3</li>   <ul>	<li>3.1</li>	<li>3.2</li>	<li>3.3</li>   </ul></ul>

The HTML validator doesnt like lists inside lists i guess. Is there an easy way to fix this?It displays the page the way i want it to, but it probably isn't the best way to accomplish this.

Link to comment
Share on other sites

Enclose the nested <ul> in a list item, like this:

<ul>  <li>Item 1</li>  <li>Item 2</li>  <li>Item 3</li>  <li>   <ul>	 <li>3.1</li>	 <li>3.2</li>	 <li>3.3</li>	</ul>  </li></ul>

Or better yet, enclose it as a child of the third item to which it belongs to anyway:

<ul>  <li>Item 1</li>  <li>Item 2</li>  <li>Item 3	<ul>	 <li>3.1</li>	 <li>3.2</li>	 <li>3.3</li>	</ul>  </li></ul>

Link to comment
Share on other sites

I ran into this too. If you want or need to use this method:

<ul>  <li>Item 1</li>  <li>Item 2</li>  <li>Item 3</li>  <li>   <ul>	 <li>3.1</li>	 <li>3.2</li>	 <li>3.3</li>	</ul>  </li></ul>

but don't want the extra bullet to appear for the nested list, you can use CSS to hide it:

<ul>  <li>Item 1</li>  <li>Item 2</li>  <li>Item 3</li>  <li style="list-style-type: none;">   <ul>	 <li>3.1</li>	 <li>3.2</li>	 <li>3.3</li>	</ul>  </li></ul>

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...