Chapter 15. Dynamic Buttons and Menus

Over the past 14 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 consider two common (and practical) web page components. First, you’ll learn how to create fancy buttons—for example, ones that light up when a guest points to them. Next, you’ll learn to build a pop-up or pop-open navigation menu, 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 6:

<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, drawn to resemble buttons, instead.

Ordinary Picture Buttons

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

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

When you use this method, HTML adds an ugly blue border around ...

Get Creating a Website: The Missing Manual, 4th 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.