This website may use cookies. More info. That's Fine x
Welcome Login

fieldset and legend tags


fieldset tag:

fieldset tag is used to group related elements in a form.

fieldset tag draws a box around the related elements.

Note: legend tag defines a caption for the fieldset element.

Attributes:

Attribute      Value        Description

disabled       disabled     Specifies that a group of related form elements should be disabled

form           form_id      Specifies one or more forms the fieldset belongs to

name           text         Specifies a name for the fieldset

 

Eg:

<!DOCTYPE html>
<html>

<head></head>

<body>
  <form>
    <fieldset>
      <legend>Personal details:</legend>
      Name: <input type="text" size="30"><br>
      Email: <input type="text" size="30"><br>
      Date of birth: <input type="text" size="10">
    </fieldset>
  </form>
</body> 

</html>

 

Outputs:

html-fieldset1

 

 

legend tag:

legend tag defines a caption for the fieldset element.

Attributes:

Attribute     Value         Description

align         top           Specifies the alignment of the caption
              bottom
              left
              right

 

 

Eg: using above example, the caption/legend is highlighted:

html-fieldset2


Created on: Wednesday, November 7, 2012 by Andrew Sin