Chapter 16. Fancy Buttons and Menus

Over the past 15 chapters, you’ve absorbed a fair amount of web wisdom. You learned to structure web pages using HTML, clothe them with style sheets, and breathe life into them with JavaScript. Now, it’s time to reap some of the rewards.

In this chapter, you’ll learn how you master three of the most common (and most practical) web design techniques. You’ll learn how to build fancy buttons—for example, ones that light up when a mouse hovers over them. You’ll also use a pop-up or pop-open menu system, so visitors can cruise around your site in style.

These features give you the chance to take the skills you’ve developed in CSS and JavaScript one step further. In other words, it’s time for your hard slogging to pay off with some snazzy website frills.

Fancy Buttons

The trends and styles of web design are always changing. In the early days of the Web, everyone used ordinary text links, like the ones you learned about in Chapter 8:

<a href="graceland.html">Visit Elvis</a>

Over time, these run-of-the-mill links started to look drab. Creative webmasters wanted more, and they decided to use small, clickable pictures instead. To do this, they pulled out the familiar <img> element and applied one of two techniques.

The most straightforward approach to creating a graphical button is to wrap the image in an anchor, as described in Chapter 8. Here’s what that looks like:

<a href="graceland.html"><img src="VisitElvis.jpeg" alt="Visit Elvis" /></a>

Unfortunately, when ...

Get Creating a Website: The Missing Manual, 3rd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.