html make a button do something code example

Example 1: how to add buttons in html

<button type="button" onclick="alert('You pressed the button!')">Click me!</button>

Example 2: how to make a button in html

<button>I'm a button</button>

Example 3: html button with link

<form action="https://google.com">
    <input type="submit" value="Go to Google" />
</form>

Example 4: html button action

A form with two submit buttons. The first submit button submits the form data to "submit_data.php", and the second submits to "send_data.php":

<form action="/submit_data.php" method="get">
  <label>Name:</label>
  <input type="text" id="uname" name="uname"><br><br>
  <label>Age:</label>
  <input type="text" id="uage" name="uage"><br><br>
  <label>Address:</label>
  <input type="text" id="uaddress" name="uaddress"><br><br>
  <button type="submit">Submit</button>
  <button type="submit" formaction="/send_data.php">Submit to another page</button>
</form>

Tags:

Css Example