Welcome to the third part of a three-part series that shows you how to design with nested HTML lists. Today we'll take what we've learned in the previous two parts to a logical conclusion: building a full-fledged drop-down menu. We will even make sure that this menu is compatible with older browsers, such as Internet Explorer 6.
Building a Drop-Down Menu with Nested HTML Lists - Start building a drop-down menu: the structural markup (Page 2 of 4 )
The first layer that I'm going to define to build the drop-down menu is the one that comprises the menu's structural markup. Essentially, this particular layer will be made up, not surprisingly, of a few nested lists, which will include the corresponding links.
Having explained that, please take a look at the following sample code, which creates the bare bones structure of this drop-down menu. Here it is:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
As I said before, the structure of the drop-down menu that I plan to build is composed of a set of nested lists, which also contain all of the pertinent links. Also, it's clear to see here that nested lists provide a solid, standard approach for constructing hierarchical menus like the one shown above.
Okay, at this moment everything looks pretty good, since the markup of the menu is already set. So, what comes next? Well, actually the menu in its current incarnation does nothing useful. This means that it's necessary to write some CSS styles that prevent all of the menu's sub items from being displayed when the web page is loaded.
Thus, in the following segment I'll be discussing in detail the definition of these CSS styles. To learn more on this topic, click on the link that appears below and keep reading.