Using button as a Generic Element

Description

If you set the type attribute to button, you create a normal button. It has no special meaning and won't do anything when you press it.

Example

The following code shows a generic button.


<!DOCTYPE HTML>
<html>
<body>
  <form method="post" action="http://example.com/form">
    <p>
      <label for="fave">Fruit: <input autofocus id="fave"
        name="fave" /></label>
    </p><!--from  ww  w. java  2s. c  om-->
    <p>
      <label for="name">Name: <input id="name" name="name" /></label>
    </p>
    <button type="button">
      Do <strong>NOT</strong> press this button
    </button>
  </form>
</body>
</html>

Click to view the demo

You can style the text contained in the button element.

Image Button


<html>
<body>
    <form action="" method="post">
        <button type="submit">Submit</button>
        <br /><br />
        <button type="reset"><b>Clear this form</b> I want to start again</button>
        <br /><br />
        <button type="button"><img src="http://www.java2s.com/style/download.png" alt="submit" /></button>
    </form>
</body><!--from  w  w  w.ja  va  2s. c  o  m-->
</html>

Click to view the demo





















Home »
  HTML CSS »
    HTML »




HTML Introduction
HTML Document
HTML Section
HTML Group Content
HTML Text Marker
HTML Table
HTML Form
HTML Embed