Hierarchical List Using HTML / CSS

I am trying to create a top-level menu that you would see in most applications using HTML, CSS and Javascript. I know that there are a ton of pre-built ones, but I want to create my own.

----------------------
| File | Edit | Help |
----------------------
| New     |
| Save    |
| Save As |
 ---------

I'm trying to use different CSS styles to get the following list in the layout right. Is this a suitable HTML structure, or would you recommend another? What CSS is necessary for the correct layout of the menu? At the moment, I'm not interested in functionality.

I am open to any HTML 5 methods, as this is just a personal project.

<ul>
    <li>File</li>
    <ul>
        <li>New</li>
        <li>Save</li>
        <li>Save As</li>
    </ul>
    <li>Edit</li>
    <ul>
        <li>Cut</li>
        <li>Copy</li>
        <li>Paste</li>
    </ul>
    <li>Help</li>
    <ul>
        <li>About</li>
    </ul>
</ul>
+3
source share
1 answer
<ul>
    <li>
        <a href="#">File</a>
        <ul>
            <li><a href="#">New</a></li>
            <li><a href="#">Save</a></li>
            <li><a href="#">Save As</a></li>
        </ul>
    </li>
    <li>
        <a href="#">Edit</a>
        <ul>
            <li><a href="#">Cut</a></li>
            <li><a href="#">Copy</a></li>
            <li><a href="#">Paste</a></li>
        </ul>
    </li>
    <li>
        <a href="#">Help</a>
        <ul>
            <li><a href="#">About</a></li>
        </ul>
    </li>
</ul>

Take a look at the sample here:

http://www.kriesi.at/archives/create-a-multilevel-dropdown-menu-with-css-and-improve-it-via-jquery

+4

All Articles