tags:

views:

71

answers:

2

Here is my CSS

   button {
    border: 0 none;
    cursor: pointer;
    padding: 0 15px 0 0;
    text-align: center;
    height: 30px;
    line-height: 30px;
    width: auto;
}
button a {
    color:white;
    text-decoration:none;
}

button.rounded {
    background: transparent url(/images/button/btn_right.png) no-repeat scroll right top;
    clear: left;
    font-size: 0.8em;
}

button span {
    display: block;
    padding: 0 0 0 15px;
    position: relative;
    white-space: nowrap;
    height: 30px;
    line-height: 30px;
}

button.rounded span {
    background: transparent url(/images/button/btn_left.png) no-repeat scroll left top;
    color: #FFFFFF;
}

button.rounded:hover {
    background-position: 100% -30px;
}

button.rounded:hover span {
    background-position: 0% -30px;
}

button::-moz-focus-inner {
border: none;
}

Here is the code for my "button" with a link in it.

<button class="rounded"><span><a href="profile.php">Profile</a></span></button>

The issue is it does not link to the href when i click on it. Anyone know why?

A: 

I believe button needs a type and value attribute.

http://www.w3schools.com/tags/tag_button.asp

You can also add onclick like:

<button onclick="location.href='/profile.php';">Profile</button>

But, since its just a regular link, you'll have a easier time using the <a> tag and styling it with CSS.

Kevin
Whats wrong with this answer? It's practically the same as the answer with 5+ upvotes.
Kevin
I didn't downvote you, but (1) the answer claims that `type` and `value` are required -- they're optional. (2) After claiming they're required, the example didn't have those attributes! (3) It didn't address the core problem in that links inside buttons are invalid markup.
Brock Adams
I got nailed on another question today where I provided nearly the exact same information as the one which was upvoted a lot..It seems I made a semantic mistake of calling something a field where I should have said property. Go figure. +1 for providing the actual javascript code for the location.
Chris Lively
I didn't downvote either, but I gave it quick thought of whether I should. Definitely would have if you had just left it before you edited it.
animuson
+7  A: 

Incidentally, it's not a CSS problem. It's a "i don't understand buttons" problem:

http://www.w3schools.com/tags/tag_button.asp

A button can have "submit", "button" or "reset" actions. If you are using the "button" action you should provide the javascript necessary in the OnClick event to navigate to the page in question.

Chris Lively