Button with link

Discussion in 'HTML & Website Design' started by Jeremy Benson, Oct 5, 2015.

  1. #1
    Hello,

    I've got a button element that I'd like to process with php. I figured the best way would be to put a link in the button. For some reason the text turns blue but nothing happens when I click the button. Not even when I click right on the text. I figured I would have to find css to make the link fill the button, but not sure why clicking directly on the text isn't working.

    <button class="btn btn-default btn-block top-buffer"><a href="php/scripts/follow_user.php?following='.$profileUser->return_username().'&follower='.$user->return_username().'">Follow</a></button>
    Code (markup):
     
    Jeremy Benson, Oct 5, 2015 IP
  2. qwikad.com

    qwikad.com Illustrious Member Affiliate Manager

    Messages:
    7,280
    Likes Received:
    1,696
    Best Answers:
    31
    Trophy Points:
    475
    #2
    My suggestion could be totally off, but why do you even need a <button>?

    Just do something like:

    <a href="php/scripts/follow_user.php?following='.$profileUser->return_username().'&follower='.$user->return_username().'
    " class="button">Follow</a>
    Code (markup):
    And then turn that class into any button you want:

    
    .button {
    background-color :#0043FF;
    border: 0.1em solid #0043FF;
    border-radius: 0.2em;
    display: inline-block;
    cursor: pointer;
    color: #ffffff !important;
    font-size: 1.2em;
    text-decoration: none;
    padding: 0.2em 0.4em 0.2em 0.4em;
    vertical-align: middle;
    }
    .button:hover {
    background-color: #003DE5;
    border: 0.1em solid #003DE5;
    color: #ffffff !important;
    text-decoration:none;
    }
    
    Code (markup):
    Working fiddle: http://jsfiddle.net/30tsjc4e/15/
     
    qwikad.com, Oct 5, 2015 IP
  3. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,999
    Best Answers:
    253
    Trophy Points:
    515
    #3
    That's my take, if it's not a FORM ELEMENT why in blazes are you wrapping it in a button tag?!? Just style the anchor and let the anchor do what an anchor does.
     
    deathshadow, Oct 5, 2015 IP
    webcosmo likes this.