My inaugural blog post is a tutorial that I promised to create for an Expression Web user a long (too long!) while ago. I promised to show him how easy it is to use CSS instead of the Interactive Buttons feature he relies on in Expression Web. The Interactive Buttons feature generates simple button images and JavaScript for you, and lets you select the font properties, size, color, and interactive behavior of your buttons. But why bother with images and all that script when you can get the same results with HTML and CSS?
Using HTML and CSS instead of the Interactive Buttons feature has many advantages, including:
If you're new to CSS or to using Expression Web, this tutorial should be useful. Please let me know what you think and if you encounter any problems. If you're not new to CSS, I'd love to hear from you too...what do you think of the CSS I'm using? If you don't want to follow all the steps and just want the final results, you can see the final markup at the end of the tutorial.
Here's what we're going to create:
Time to give the buttons some color and jazz things up...
Next, we'll make the text appear centered within each button.
Next, we'll make hyperlinks out of the buttons.
In your browser, notice that when you put your pointer over any of your buttons, the background color changes no matter where your pointer is on the button...this is by design, BUT you can't click the hyperlink unless your pointer is directly over text in a button. We'll fix that next...
Here's the final markup from this tutorial:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <meta http-equiv="Content-Language" content="en-us" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled 1</title> <style type="text/css"> #nav_menu li { border: 2px solid #000000; list-style-type: none; float: left; width: 4em; background-color: #800080; text-align: center; margin-right: 1px; margin-left: 1px; } #nav_menu a { font-family: Arial, Helvetica, sans-serif; color: #FFFFFF; text-decoration: none; display: block; } #nav_menu li:hover { background-color: #FF0066; } </style> </head> <body> <ul id="nav_menu"> <li> <a target="_blank" href="http://blogs.msdn.com/anna">one</a></li> <li> <a target="_blank" href="http://blogs.msdn.com/anna">two</a></li> <li> <a target="_blank" href="http://blogs.msdn.com/anna">three</a></li> </ul> </body> </html>