aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes Embedding Lists in XHTML Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Embedding Lists in XHTML" Watch "Embedding Lists in XHTML" New topic
Author

Embedding Lists in XHTML

Corey McGlone
Ranch Hand

Joined: Dec 20, 2001
Posts: 3271
Hey folks,

I always thought this was a simple thing to do, but, in XHTML, I'm getting some strange results. Basically, I have an unordered list and, as one of my list elements, I want to have another unordered list, something like this:



Unfortunately, that just doesn't display very well. I get the "dot" for the sublist and I end up with an additional break in the middle of my list. Any quick ideas?

Thanks,
Corey


SCJP Tipline, etc.
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
get rid of the li element around the ul. It is not needed

Eric
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60059
    
  65

And you can change the visuals by applying CSS rules to the list and its elements. Though I have found that the browsers can be quirky about it...


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Corey McGlone
Ranch Hand

Joined: Dec 20, 2001
Posts: 3271
Originally posted by Eric Pascarello:
get rid of the li element around the ul. It is not needed


Well, that's what I had started with. Unfortunately, in XHTML, it appears that it is needed. If I run the XHTML through the W3C Validator, it won't pass validation unless the li element encloses the ul element. Perhaps I'll just try to work it out with CSS.
Mike Firkser
Ranch Hand

Joined: Oct 21, 2003
Posts: 247

What I have found works is if you embed the new list in the previous <li> tag:



Mike Firkser
Rutgers '84
Corey McGlone
Ranch Hand

Joined: Dec 20, 2001
Posts: 3271
Originally posted by Mike Rutgers:
What I have found works is if you embed the new list in the previous <li> tag:


Ah! Perfect! Not sure why I hadn't tried that earlier, but that does just what I want. Thanks, Mike.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Embedding Lists in XHTML
 
Similar Threads
UL list in a JTextPane
selecting pure text in jquery
reading a nested list with javascript
jQuery -- add remove list item
unordered list with hyphen