0

Does any one know how I can place multiple html buttons that act as links on the same html page?

I am currently doing this:

<form action="http://justchillinc.wix.com/just-chill">       
    <input type="submit" value="Just Chill">
</form>
<form action="http://google.com">
    <input type="submit" value="Google">
</form>
Kara
  • 6,115
  • 16
  • 50
  • 57

4 Answers4

1

not styled brilliant but you get the idea... any a tag with a class of button will be styled the same.

.button{
  display:inline-block;
  text-decoration:none;
  color:yellow;
  font-weight:bold;
  min-width:132px;
  min-height:37px;
  border:1px solid black;
  border-radius:12px;
  text-align:center;
  background-color:gray;
  box-shadow:8px 8px 8px gray;
  margin:10px;
  
  }
.button:active{
  background-color:green;
position:relative;
  top:8px;
  left:8px;

}
<a href="http://google.com" class="button" target="_blank">Link Here</a>
<a href="http://google.com" class="button" target="_blank">Link Here</a>
<a href="http://google.com" class="button" target="_blank">Link Here</a>
<a href="http://google.com" class="button" target="_blank">Link Here</a>
Billy
  • 2,448
  • 1
  • 10
  • 13
0

The way you do it is already good. Here are some other methods to do this:

  1. With the a tag and some custom css (http://jsfiddle.net/pp4eufat/)

    HTML:

    <a class="button" href="http://justchillinc.wix.com/just-chill">Just chill</a>
    

    CSS:

    a.button {
        padding: 5px 10px;
        background-color: #ddd;
        color: #222;
        text-decoration: none;
    }
    

    You can easily assign the button class to submit buttons or similar to get a consistent button look all over your page.

  2. With a button and javascript (http://jsfiddle.net/gdfx5fd3/)

    Code:

    <button onclick="window.location.href='http://google.com';">Google</button>
    

    The important part is onclick="location.href='http://google.com';". It tells the browser to open http://google.com when the user clicks the button. The disadvantage is that the user has to have javascript enabled (nearly everybody has it enabled, so this isn't a big problem)

Max Klein
  • 468
  • 1
  • 6
  • 22
0

From:

<form action="http://justchillinc.wix.com/just-chill">       
    <input type="submit" value="Just Chill">
</form>
<form action="http://google.com">
    <input type="submit" value="Google">
</form>

To:

<form method="post" action="http://justchillinc.wix.com/just-chill">       
    <input type="submit" value="Just Chill">
</form>
<form method="post" action="http://google.com">
    <input type="submit" value="Google">
</form>
N kubo
  • 1
  • 1
  • 2
0

This is a way to create multiple links if you didn't want to copy and paste the same link.

<button class= "card" id="card-1">1</button>
<button class= "card" id="card-2">2</button>
<button class= "card" id="card-3">3</button>
<button class= "card" id="card-4">4</button>
<button class= "card" id="card-5">5</button>
<button class= "card" id="card-6">6</button>
<button class= "card" id="card-7">7</button>
<button class= "card" id="card-8">8</button>
<button class= "card" id="card-">9</button>


<script type="text/javascript">
    var elements = document.getElementsByClassName("card");
    for (i = 0; i < elements.length; i ++)
    {
        (function(){
        elements[i].onclick = function () {
        location.href = "https://stackoverflow.com/questions/27888246/how-can-i-place-multiple-html-buttons-that-act-as-links-on-the-same-page#";
        };}());
    };
</script> 
l33tHax0r
  • 1,384
  • 1
  • 15
  • 31