Welcome to WebmasterWorld Guest from 3.234.210.89

Forum Moderators: phranque

Message Too Old, No Replies

Buttons: do you use A, DIV, or BUTTON?

     
7:31 pm on Jul 17, 2018 (gmt 0)

Senior Member

WebmasterWorld Senior Member 5+ Year Member Top Contributors Of The Month

joined:Mar 15, 2013
posts: 1205
votes: 120


As I'm rebuilding, I'm wondering about this seemingly minor question: should I use a BUTTON tag, DIV tag, or A?

I used to do this:

# CSS
.button {
padding: 5px 25px;
color: #FFF;
text-align: center;
font-weight: bold;
font-size: 11px;

border: 1px solid #48729B;
border-radius: 3px;

background: #739ABF;
background: linear-gradient(top, #8AAACA 0%, #5685B2 100%);
}

.rel { position: relative }

# HTML
<div class="button">
<div class="rel">Click</div>
</div>


(with the class="rel" in the middle as a fix for when older browsers didn't show the text as antialiased)

More recently I changed it from a DIV to an A with display: block because, logically, an A should be interpreted as something that should be clicked, where a DIV doesn't.

But now I can't quite remember... why is it that I'm not using BUTTON?