SitePoint Code Challenge: CSS – Drop Down Menus

Share this article

Next up in our series of SitePoint forums quick code challenges we’re going to move away from the esoteric and cute (checkerboards, spinning dice) to something more concrete and practical: drop down menus. You don’t have to go far to spot one — there’s one on the SitePoint homepage.

Here’s a copy of the relevant HTML:

<!DOCTYPE html>
  <style type="text/css">
    /* Put your css here */
    <li><a href="" >Home</a></li>
    <li><a href="">Forums</a>
        <li><a href="" >Web Content</a></li>
        <li><a href="" >Design Your Site</a></li>
        <li><a href="" >Program Your Site</a></li>
        <li><a href="" >Host Your Site</a></li>
        <li><a href="" >Manage Your Site</a></li>
        <li><a href="" >Community Center</a></li>
    <li><a style="cursor:default;">Resources</a>
        <li><a href="" >Newsletters</a></li>
        <li><a href="" >Podcast</a></li>
        <li><a href="" >CSS Reference</a></li>
        <li><a href="" >HTML Reference</a></li>
        <li><a href="" >Javascript Reference</a></li>
        <li><a href="" >Tools</a></li>
        <li><a href="" >HTML5 Dev Center</a></li>
        <li><a href="" >Hosting Reviews</a></li>
    <li><a href="" target="_blank">Deals</a></li>
    <li><a href="" >Bookstore</a>
        <li><a href="" >Find the right book</a></li>
        <li><a href="" >New Releases</a></li>
        <li><a href="" >Web Development Books</a></li>
        <li><a href="" >Web Design Books</a></li>
        <li><a href="" >Business & Marketing Books</a></li>
        <li><a href="" >Books for Educators</a></li>
        <li><a href="" >Frequently Asked Questions</a></li>
        <li><a href="" >Shipping Rates & Times</a></li>
    <li><a href="" >Market</a></li>
    <li><a href="" >Courses</a></li>
    <li><a href="" >Sitepoint Network</a>
        <li><a href="" >JSPro</a></li>
        <li><a href="" >BuildMobile</a></li>
        <li><a href="" >DesignFestival</a></li>
        <li><a href="" >RubySource</a></li>
        <li><a href="" >CloudSpring</a></li>
        <li><a href="" >PHPMaster</a></li>
        <li><a href="" >Learnable</a></li>
        <li><a href="" >SitePoint Market</a></li>

SitePoint uses a jQuery plugin called Superfish to insure backward compatibility with older browsers, even IE 6. In this exercise we will work only with the CSS needed to create the effect since modern browsers can achieve it without any JavaScript.

Beginner Challenge
Replicate the SitePoint homepage drop downs in CSS only. You’ll need to make use of the li:hover attribute, position relative and position absolute.
Don’t fret to much about the color, font and spacing, the goal here is to master and understand the effect of a drop down menu.

Advanced Challenge
Use CSS media queries to change the menu into an accordion for phones. Keep in mind that phones register the first touch on an element as a :hover.

Expert Challenge
Using CSS transitions, make the menus fold or fade in, dissolve out, or whatever suits your fancy. You may need to modify the HTML for more elaborate effects.

Have fun!

You can find the answers here.

Sarah HawkSarah Hawk
View Author

Formerly a developer in the corporate world, HAWK (known as Sarah by her mother) said goodbye to the code and succumbed to the lure of social media to become the Community Manager for the SitePoint network. Now Hawk is working with Discourse to build their product and community.

challengecode challengeCSSforums
Share this article
Read Next
Get the freshest news and resources for developers, designers and digital creators in your inbox each week
Loading form