Getting Started:
To start this off we'll create our HTML document. We're going to start this off like any other HTML document we'd create.
CODE
<html>
<title>Drop Down Menu</title>
<meta http-equiv="Content-Language" content="English" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="stylesheet" type="text/css" href="menu.css" media="screen" />
<!---Go ahead and insert your meta info and link your page to a CSS, you'll need this later----!>
</head>
<body>
</body>
<title>Drop Down Menu</title>
<meta http-equiv="Content-Language" content="English" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="stylesheet" type="text/css" href="menu.css" media="screen" />
<!---Go ahead and insert your meta info and link your page to a CSS, you'll need this later----!>
</head>
<body>
</body>
Alright now we're set to get started. Pay close attention to the code because we are going to be using a lot of the same elements over and over, it can get you confused very quickly.
Let's open up a div tag for our menu.
CODE
<html>
<title>Drop Down Menu</title>
<meta http-equiv="Content-Language" content="English" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="stylesheet" type="text/css" href="menu.css" media="screen" />
<!---Go ahead and insert your meta info and link your page to a CSS, you'll need this later----!>
</head>
<body>
<div id="menu">
</div>
</body>
<title>Drop Down Menu</title>
<meta http-equiv="Content-Language" content="English" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="stylesheet" type="text/css" href="menu.css" media="screen" />
<!---Go ahead and insert your meta info and link your page to a CSS, you'll need this later----!>
</head>
<body>
<div id="menu">
</div>
</body>
From this point on, everything we create for our menu will be inside this div.
Alright, now if you look at the live example you'll see the "Home" section.
CODE
<ul>
<li><h2>Home</h2>
<ul>
<li><a href="http://www.nascentdescent.com" title="Home Page">Home</a>
</li>
</ul>
</li>
</ul>
<li><h2>Home</h2>
<ul>
<li><a href="http://www.nascentdescent.com" title="Home Page">Home</a>
</li>
</ul>
</li>
</ul>
This is just made out of different list components. Rather simple, just make sure you close all the tags that need to be closed. Insert this code inside the div.
Now we'll move to the "About Us" section, this code will be very similar to the above code. Pay attention and see if you can see the differences.
CODE
<ul>
<li><h2>About Us</h2>
<ul>
<li><a href="http://www.nascentdescent.com" title="About Us">Who Am I?</a></li>
<li><a href="http://www.nascentdescent.com" title="About Us">What is my goal?</a>
<li><a href="http://www.nascentdescent.com" title="About Us">How do I plan on suceeding?</a>
</li>
</ul>
</li>
</ul>
<li><h2>About Us</h2>
<ul>
<li><a href="http://www.nascentdescent.com" title="About Us">Who Am I?</a></li>
<li><a href="http://www.nascentdescent.com" title="About Us">What is my goal?</a>
<li><a href="http://www.nascentdescent.com" title="About Us">How do I plan on suceeding?</a>
</li>
</ul>
</li>
</ul>
All we did was create a couple extra list elements to create more than one option in the drop box.
Okay now this is where we can make our drop box a little more convenient for users. I'm going to create some options under the "Portfolio" Section. Hover over "Vectors" to see what this will look like.
CODE
<ul>
<li><h2>Portfolio</h2>
<ul>
<li><a href="http://www.nascentdescent.com" title="Portfoilio">Web Templates</a></li>
<li><a href="http://www.nascentdescent.com" title="Portfolio">Paintings</a>
<li><a href="http://www.nascentdescent.com" title="Portfolio">Photos</a>
<li><a href="http://www.nascentdescent.com" title="Portfolio">Vectors</a>
<ul>
<li><a href="http://www.nascentdescent.com">People</a>
<li><a href="http://www.nascentdescent.com">Objects</a>
<li><a href="http://www.nascentdescent.com">Cars</a>
<li><a href="http://www.nascentdescent.com">Places</a>
</li>
</li>
</li>
</li>
</li>
</li>
</ul>
</li>
</ul>
</li>
</ul>
<li><h2>Portfolio</h2>
<ul>
<li><a href="http://www.nascentdescent.com" title="Portfoilio">Web Templates</a></li>
<li><a href="http://www.nascentdescent.com" title="Portfolio">Paintings</a>
<li><a href="http://www.nascentdescent.com" title="Portfolio">Photos</a>
<li><a href="http://www.nascentdescent.com" title="Portfolio">Vectors</a>
<ul>
<li><a href="http://www.nascentdescent.com">People</a>
<li><a href="http://www.nascentdescent.com">Objects</a>
<li><a href="http://www.nascentdescent.com">Cars</a>
<li><a href="http://www.nascentdescent.com">Places</a>
</li>
</li>
</li>
</li>
</li>
</li>
</ul>
</li>
</ul>
</li>
</ul>
The "Contact Us" section is the same as the "About Us" Section
CODE
<ul>
<li><h2>Contact Us</h2>
<ul>
<li><a href="http://www.nascentdescent.com" title="About Us">Email Me</a></li>
<li><a href="http://www.nascentdescent.com" title="About Us">Send me a letter</a>
<li><a href="http://www.nascentdescent.com" title="About Us">Give me a Call</a>
</li>
</ul>
</li>
</ul>
<li><h2>Contact Us</h2>
<ul>
<li><a href="http://www.nascentdescent.com" title="About Us">Email Me</a></li>
<li><a href="http://www.nascentdescent.com" title="About Us">Send me a letter</a>
<li><a href="http://www.nascentdescent.com" title="About Us">Give me a Call</a>
</li>
</ul>
</li>
</ul>
That's it for your HTML it should look something like this when you're done.
CODE
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Drop Down Menu</title>
<meta http-equiv="Content-Language" content="English" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="stylesheet" type="text/css" href="menu.css" media="screen" />
</head>
<body>
<div id="menu">
<ul>
<li><h2>Home</h2>
<ul>
<li><a href="http://www.nascentdescent.com" title="Home Page">Home</a>
</li>
</ul>
</li>
</ul>
<ul>
<li><h2>About Us</h2>
<ul>
<li><a href="http://www.nascentdescent.com" title="About Us">Who Am I?</a></li>
<li><a href="http://www.nascentdescent.com" title="About Us">What is my goal?</a>
<li><a href="http://www.nascentdescent.com" title="About Us">How do I plan on suceeding?</a>
</li>
</ul>
</li>
</ul>
<ul>
<li><h2>Portfolio</h2>
<ul>
<li><a href="http://www.nascentdescent.com" title="SEO Consultants Directory Example">Web Templates</a></li>
<li><a href="http://www.nascentdescent.com">Paintings</a>
<li><a href="http://www.nascentdescent.com">Photos</a>
<li><a href="http://www.nascentdescent.com">Vectors</a>
<ul>
<li><a href="http://www.nascentdescent.com">People</a>
<li><a href="http://www.nascentdescent.com">Objects</a>
<li><a href="http://www.nascentdescent.com">Cars</a>
<li><a href="http://www.nascentdescent.com">Places</a>
</li>
</li>
</li>
</li>
</li>
</li>
</ul>
</li>
</ul>
</li>
</ul>
<ul>
<li><h2>Contact Us</h2>
<ul>
<li><a href="http://www.nascentdescent.com" title="About Us">Email Me</a></li>
<li><a href="http://www.nascentdescent.com" title="About Us">Send me a letter</a>
<li><a href="http://www.nascentdescent.com" title="About Us">Give me a Call</a>
</li>
</ul>
</li>
</ul>
</div>
</body>
</html>
Time to create the CSS, this is what will add the style to the HTML document.
Now the CSS is really pretty self explained, I'm just going to post it and you can ask questions if you need to.
CODE
#menu {
width: 100%;
background: #eee;
float: left;
}
#menu ul {
list-style: none;
margin: 0;
padding: 0;
width: 12em;
float: left;
}
#menu a, #menu h2 {
font: bold 11px/16px arial, helvetica, sans-serif;
display: block;
border-width: 1px;
border-style: solid;
border-color: #ccc #888 #555 #bbb;
margin: 0;
padding: 2px 3px;
}
#menu h2 {
color: #fff;
background: #000;
text-transform: uppercase;
}
#menu a {
color: #000;
background: #efefef;
text-decoration: none;
}
#menu a:hover {
color: #a00;
background: #fff;
}
#menu li {position: relative;}
#menu ul ul {
position: absolute;
z-index: 500;
}
#menu ul ul ul {
top: 0;
left: 100%;
}
div#menu ul ul,
div#menu ul li:hover ul ul,
div#menu ul ul li:hover ul ul
{display: none;}
div#menu ul li:hover ul,
div#menu ul ul li:hover ul,
div#menu ul ul ul li:hover ul
{display: block;}
<!--[if IE]>
<style type="text/css" media="screen">
body {
behavior: url(csshover.htc);
font-size: 100%;
}
#menu ul li {float: left; width: 100%;}
#menu ul li a {height: 1%;}
#menu a, #menu h2 {
font: bold 0.7em/1.4em arial, helvetica, sans-serif;
}
Enjoy!
Kevin DiGennaro
