We help IT Professionals succeed at work.

2-level CSS Horizontal Menu

8,169 Views
Last Modified: 2013-11-19
Does anyone have a good example of a pure CSS horizontal menu that supports sub menus and sub sub menus? Please see xml representation of the menu.

Any help appreciated.  Thanks.  I would have given more points if I had more... Sorry.
<Menus>
   <Menu level='1'>Menu1</Menu>
   <Menu level='1'>Menu2
      <Submenu level='2'>Menu2-Submenu1
          <Subsubmenu level='3'>Menu2-Submenu1-Subsubmenu1</Subsubmenu>
      </Submenu>
   <Menu>
   <Menu level=1'>Menu3
      <Submenu level='2'>Menu2-Submenu2</Submenu>
   </Menu>
</Menus>

Open in new window

Comment
Watch Question

Consultant & Challenge Subduer
CERTIFIED EXPERT
Top Expert 2009
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION
CERTIFIED EXPERT
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION
CERTIFIED EXPERT

Commented:
David S.Consultant & Challenge Subduer
CERTIFIED EXPERT
Top Expert 2009

Commented:
Many of the menus at cssplay.co.uk, including the two Daydreams linked to specifically, use a nasty hack to make them work in IE5-6/Win. They only validate because they use conditional comments to only show the invalid nesting to IE5-6/Win. They also use <table>s that would otherwise be unnecessary and are semantically incorrect.
CERTIFIED EXPERT

Commented:
Kravimir, your suggestion contains  csshover.htc, and also uses hacks and conditional comments to allow the code to validate. I'm not sure what your point is; it's a challenge to have a multiple dropdown in pure CSS.
David S.Consultant & Challenge Subduer
CERTIFIED EXPERT
Top Expert 2009

Commented:
I realize this is a bit of a lecture, but they are important issues, so please bear with me.

I consider CSS hacks to be a necessary evil in many cases, due to the differences in browser implementations, especially of IE5-7. (I'm not saying that you shouldn't try to find better alternatives to them though.) However, markup hacks should be avoided whenever possible. (Why I consider them different comes down to the different purposes of [X]HTML and CSS.) I don't have a problem with conditional comments when used to hide stylesheets from other browsers because they give better control than CSS hacks and, when used with care, are more future proof.

The term "pure CSS" is a misnomer. A stylesheet by itself is useless. You need some structure, often [X]HTML, for the styles to be applied to.

Due to IE5-6's support for the :hover pseudo-class being limited to <a> elements, you need more than just [X]HTML and CSS to make fly-out and drop-down menus work in them. The best way, though support for it will be disabled in some users' browsers, is to use JavaScript/JScript, either directly or through an .htc file. The other way is to use that nasty hack which uses conditional comments and <table>s. (Because JavaScript support isn't always enabled, I recommend people to always have top-level items in navigation menus be actual links and to include a sitemap whenever possible.)

Author

Commented:
Thank you for your input.  I will try it out tonight and let you both know the results.

Author

Commented:
Thanks Kravimir and DayDreams.  They're both good solutions.  
CERTIFIED EXPERT

Commented:
NesFuratu, thanks for the points and the excellent grade!

Author

Commented:
This is another great site to generate the menu for you... No obvious hacks involved it seems.

http://ryanhellyer.net/dropdowns/
CERTIFIED EXPERT

Commented:
NesFuratu, nice find.. thank you again:-)
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.