Grouping Form Elements with fieldset element

Description

To group some of the elements together, you can use the fieldset element. It has local attributes:name, form, disabled.

Example

You can see how the fieldset element is applied in the following code.


<!DOCTYPE HTML>
<html>
<body>
  <form method="post" action="http://example.com/form">
    <fieldset>
      <p>
        <label for="name">Name: <input id="name" name="name" /></label>
      </p><!-- w ww . jav  a  2s  .  c o m-->
      <p>
        <label for="name">City: <input id="city" name="city" /></label>
      </p>
    </fieldset>
    <fieldset>
      <p>
        <label for="fave1">#1: <input id="fave1" name="fave1" /></label>
      </p>
      <p>
        <label for="fave2">#2: <input id="fave2" name="fave2" /></label>
      </p>
      <p>
        <label for="fave3">#3: <input id="fave3" name="fave3" /></label>
      </p>
    </fieldset>
    <button>Submit Vote</button>
  </form>
</body>
</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