Re-Rediscovering the Button Tag

Simply-Buttons Technique

» December 6th, 2008 » 6 Comments

UPDATE! Version 2 is out, check it out ».

TESTED IE6 IE7 FF(PC/MAC) Safari SafariMobile Opera(PC/MAC)

Background

So I have decided to share a button technique I have been using for awhile with the public. I had some time a while back and read a few interesting articles on buttons:

These got me thinking… these techniques are pretty nice, but I think they can meet somewhere in the middle and make something even better. After a little work I came up with the “Simply Buttons Technique”.

How it Works

The markup is pretty simple, as you can see below. The thing to notice here is that both the button and link tags each have a nested-nested span tag (…say that 3 times fast!).

<button type="button" value="Button">
  <span><span>Button</span></span>
</button>

<a class="button">
  <span><span>Button</span></span>
</a>

Now there are two parts involved here, the first thing to know here is that this method will work with just CSS. However it works a little better with some Javascript enhancements. Let’s take a look:

Generic (no javascript)

YouTube Style (no javascript)

Now we see the buttons load nicely here, we are using the Sliding Doors Technique. The caveats are:

  • There are outlines on the buttons.
  • The text is selectable.
  • These buttons are not mobile friendly (the button tag).

The Solution

In comes the the Simply Buttons Javascript component. It is currently written using the Prototype framework. I will be writing a version that is framework independent soon, but this works just as well. The library solves the caveats above as you can see below:

Generic (w/ javascript)

YouTube Style (w/ javascript)

Below is the object you can configure to further customize the buttons to suite your design.

this.options = Object.extend({
  hyperlinkSelector: 'a.button',
  activeButtonClass: 'button_active',
  states: {
    outer: {
      active: {
        backgroundPosition: 'bottom left'
      },
      inactive: {
        backgroundPosition: 'top left'
      }
    },
    inner: {
      active: {
        backgroundPosition: 'bottom right'
      },
      inactive: {
        backgroundPosition: 'top right'
      }
    }
  }
}, options || {});

Download the Code/Sample

Below you can download not only the core CSS and Javascript files but you also will get a few samples. I am not the greatest at tutorials so I will update this post as feedback comes in, however there are quite a few comments throughout the files. The important files are: stylesheets/buttons.css, javascripts/buttons.js.

Thoughts

I will be updating the Javascript in the weeks to come with a version that is not framework dependent. Other than that I would love to hear thoughts, suggestions, or even new takes on this technique. Let’s bring the button back!

NOTE To see this button style in action, check out the Contact Page.

Spread the Word
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • DZone
  • LinkedIn
  • NewsVine
  • Reddit
  • BlinkList
  • StumbleUpon
  • Technorati
  • Yahoo! Buzz
  • Propeller

Share

Comments

6 Responses to “Simply-Buttons Technique”

  1. Nice post! Thanks for including both javascript and CSS options!

  2. Jake-DesignerFied on December 9th, 2008 at 7:53 pm
  3. Not a problem, let me know if you have any questions about how to customize them to get your look and feel.

  4. Kevin on December 9th, 2008 at 9:02 pm
  5. What a nice way to kick-start a new blog. Great post! Short, practical and to the point :-)

  6. Morgan Roderick on December 10th, 2008 at 11:28 am
  7. I am getting issues In IE. I pasted the css option steps as given.Still Buttons are not working.Can you help me?

  8. Aliya on November 23rd, 2009 at 10:18 pm
  9. Tnks for share ! and congratulations !

    Daniel (From Argentina)

  10. Daniel on February 3rd, 2010 at 4:31 am
  11. Hi, I found this post while searching for help with JavaScript. I’ve recently switched browsers from Google Chrome to Mozilla Firefox 3.1. Just recently I seem to have a problem with loading JavaScript. Everytime I browse website that needs Javascript, my browser does not load and I get a “runtime error javascript.JSException: Unknown name”. I can’t seem to find out how to fix it. Any help is very appreciated! Thanks

  12. Nicki Dewick on March 4th, 2010 at 5:42 pm

Trackbacks/Pingbacks

  1. Pretty Buttons With The “Simply Buttons Technique” - DesignerFied.com

Leave a Reply