HTML <fieldset> tagS2C Home   « HTML <fieldset> tag

Definition

The <fieldset> tag is used for grouping form elements together.

The <fieldset> tag is often used together with the <legend> tag to give meaningful content information about the <form> control content.

Example


<form action="../../htmladvanced/simpleform.html" method="get">
  <fieldset>
    <legend>Pie Survey</legend> 
    <p>Name:<input type="text" name="name" /></p>
    <p>Which pie do you prefer?:</p>
    <p><input type="radio" name="pie" checked="checked" value="chicken" /> Chicken</p>
    <p><input type="radio" name="pie" value="fish" /> Fish</p>
    <p><input type="radio" name="pie" value="shepherds" /> Shepherds</p>
    <p>Select a pie shape:</p>
    <p><select name="shape">
      <optgroup label="Normal">
        <option value="round">round</option>
        <option value="square">square</option>
      </optgroup>
      <optgroup label="Custom">
        <option value="hexagon">hexagon</option>
        <option value="star">star</option>
        <option value="triangle">triangle</option>
      </optgroup>
    </select></p>
    <p>Submit your information:</p>
    <p><button type="submit" value="Submit">Submit</button></p>
  </fieldset>
</form>
Pie Survey

Name:

Which pie do you prefer?:

Chicken

Fish

Shepherds

Select a pie shape:

Submit your information:

Attributes

The following attributes can be used with the <fieldset> tag.


<fieldset> Specific Attributes
Attribute Value Description Example
disabledempty string or disabledDisables all form control descendants of the <fieldset> tag.

<fieldset disabled>Form elements</fieldset>
<fieldset disabled="disabled">Form elements</fieldset>
formform idThe form to associate the the <fieldset> tag with.

<fieldset form="formId">Form elements</fieldset>
namenameSpecifies a name for the <fieldset> tag.

<fieldset name="aName">Form elements</fieldset>
<fieldset> Global Attributes
Attribute Description Example
Common
classSpecifies a classname for the element allowing you to apply the style of the predefined class to the content.

<fieldset class="name">Form elements</fieldset>
idSpecifies a unique id for the element allowing you to apply the style of the predefined id to the content.

<fieldset id="name">Form elements</fieldset>
styleSpecifies an inline style for the element allowing you to apply the style to the contentt.

<fieldset style="color:red;">Form elements</fieldset>
titleSpecifies an inline style for the element allowing you to apply the style to the content.

<fieldset title="Content info">Form elements</fieldset>
Keyboard
accesskeySpecifies a keyboard shortcut to associate with the element.

<fieldset accesskey="a">Form elements</fieldset>
tabindexSpecifies a tab order for the element.

<fieldset tabindex="1">Form elements</fieldset>
Language
dirSpecifies the directional flow of the content.

<!-- The text will flow from left to right -->
<fieldset dir="ltr">Form elements</fieldset>
<!-- The text will flow from right to left -->
<fieldset dir="rtl">Form elements</fieldset>
langSpecifies a language code for the content of the element.

<fieldset lang="en">Form elements</fieldset>
spellcheckSpecifies an inline style for the element allowing you to apply the style to the contentt.

<!-- Valid values true and false. -->
<!-- Default inherited / browser specific. -->
<fieldset spellcheck="true">Form elements</fieldset> 
translateSpecifies an inline style for the element allowing you to apply the style to the content.

<!-- Valid values yes and no. -->
<!-- Default yes. -->
<fieldset translate="no">Form elements</fieldset> 
Miscellaneous
contenteditableSpecifies whether the content of the element is editable.

<!-- Valid values true and false. -->
<!-- Default inherited. -->
<fieldset contenteditable="true">Form elements</fieldset> 
draggableSpecifies whether the element is draggable.

<!-- Valid values true and false. -->
<!-- Default browser specific. -->
<fieldset draggable="true">Form elements</fieldset>
hiddenSpecifies whether the element is not yet, or no longer, relevant.

<!-- Valid values an empty string or hidden -->
<fieldset hidden>Form elements</fieldset> 
<fieldset hidden="hidden">Form elements</fieldset> 
<fieldset> Event Attributes
Attribute Description Example
Document Element
oncopyThe script to be run when the user copies the content of an element.

 <!-- Executes go() function -->
<fieldset oncopy="go()">Form elements</fieldset> 
oncutThe script to be run when the user cuts the content of an element.

 <!-- Executes go() function -->
<fieldset oncut="go()">Form elements</fieldset>
onpasteThe script to be run when the user pastes some content into an element.

 <!-- Executes go() function -->
<fieldset onpaste="go()">Form elements</fieldset>
Drag and Drop
ondragThe script to be run when an element is dragged.

 <!-- Executes go() function -->
<fieldset ondrag="go()">Form elements</fieldset>
ondragendThe script to be run when an element has stopped being dragged.

 <!-- Executes go() function -->
<fieldset ondragend="go()">Form elements</fieldset>
ondragenterThe script to be run when an element has been dragged to a valid drop target.

 <!-- Executes go() function -->
<fieldset ondragenter="go()">Form elements</fieldset>
ondragleaveThe script to be run when an element leaves a valid drop target.

 <!-- Executes go() function -->
<fieldset ondragleave="go()">Form elements</fieldset>
ondragoverThe script to be run when an element is being dragged over a valid drop target.

 <!-- Executes go() function -->
<fieldset ondragover="go()">Form elements</fieldset>
ondragstartThe script to be run at the start of a drag operation.

 <!-- Executes go() function -->
<fieldset ondragstart="go()">Form elements</fieldset>
ondropThe script to be run when a dragged element is being dropped.

 <!-- Executes go() function -->
<fieldset ondrop="go()">Form elements</fieldset>
Form
onblurThe script to be run when the element loses focus.

 <!-- Executes go() function -->
<fieldset onblur="go()">Form elements</fieldset>
onchangeThe script to be run when object changed and attempt to leave field.

 <!-- Executes go() function -->
<fieldset onchange="go()">Form elements</fieldset>
oncontextmenuThe script to be run when a context menu is triggered.

 <!-- Executes go() function -->
<fieldset oncontextmenu="go()">Form elements</fieldset>
onfocusThe script to be run when the element gets focus.

 <!-- Executes go() function -->
<fieldset onfocus="go()">Form elements</fieldset>
oninputThe script to be run when an element gets user input.

 <!-- Executes go() function -->
<fieldset oninput="go()">Form elements</fieldset>
oninvalidThe script to be run when an element is invalid.

 <!-- Executes go() function -->
<fieldset oninvalid="go()">Form elements</fieldset>
onresetThe script to be run when a dragged element is being dropped.

 <!-- Executes go() function -->
<fieldset onreset="go()">Form elements</fieldset>
onselectThe script to be run when some or all of the contents of an object are selected.

 <!-- Executes go() function -->
<fieldset onselect="go()">Form elements</fieldset>
onsubmitThe script to be run when a form is submitted.

 <!-- Executes go() function -->
<fieldset onsubmit="go()">Form elements</fieldset>
Keyboard
onkeydownThe script to be run when an element is in focus and keyboard key is pressed down.

 <!-- Executes go() function -->
<fieldset onkeydown="go()">Form elements</fieldset>
onkeypressThe script to be run when an element is in focus and keyboard key is pressed down and released.

 <!-- Executes go() function -->
<fieldset onkeypress="go()">Form elements</fieldset>
onkeyupThe script to be run when an element is in focus and keyboard key is released.

 <!-- Executes go() function -->
<fieldset onkeyup="go()">Form elements</fieldset>
Media
onabortThe script code to be run on abort.

 <!-- Executes go() function -->
<fieldset onabort="go()">Form elements</fieldset>
oncanplayThe script to be run when a file has buffered enough so it is ready to start playing.

 <!-- Executes go() function -->
<fieldset oncanplay="go()">Form elements</fieldset>
oncanplaythroughThe script to be run when a file can be played all the way to the end without further need of buffering.

 <!-- Executes go() function -->
<fieldset oncanplaythrough="go()">Form elements</fieldset>
oncuechangeThe script to be run when the cue changes when using the track element.

 <!-- Executes go() function -->
<fieldset oncuechange="go()">Form elements</fieldset>
ondurationchangeThe script to be run when the length of the media is changed.

 <!-- Executes go() function -->
<fieldset ondurationchange="go()">Form elements</fieldset>
onemptiedThe script to be run when a media resource element suddenly becomes empty, usually due to an error.

 <!-- Executes go() function -->
<fieldset onemptied="go()">Form elements</fieldset>
onendedThe script to be run when the media has reach the end.

 <!-- Executes go() function -->
<fieldset onended="go()">Form elements</fieldset>
onloadeddataThe script to be run when media data is loaded and playback can start.

 <!-- Executes go() function -->
<fieldset onloadeddata="go()">Form elements</fieldset>
onloadedmetadataThe script to be run when metadata has been loaded.

 <!-- Executes go() function -->
<fieldset onloadedmetadata="go()">Form elements</fieldset>
onloadstartThe script to be run whenthe media resource has started loading.

 <!-- Executes go() function -->
<fieldset onloadstart="go()">Form elements</fieldset>
onpauseThe script to be run when the media resource has been paused.

 <!-- Executes go() function -->
<fieldset onpause="go()">Form elements</fieldset>
onplayThe script to be run when the media resource starts playback.

 <!-- Executes go() function -->
<fieldset onplay="go()">Form elements</fieldset>
onplayingThe script to be run when when playback has already begun.

 <!-- Executes go() function -->
<fieldset onplaying="go()">Form elements</fieldset>
onprogressThe script to be run when the browser is fetching the media data.

 <!-- Executes go() function -->
<fieldset onprogress="go()">Form elements</fieldset>
onratechangeThe script to be run when the playback rate changes.

 <!-- Executes go() function -->
<fieldset onratechange="go()">Form elements</fieldset>
onseekedThe script to be run when the seeking attribute is set to false indicating that seeking has finished.

 <!-- Executes go() function -->
<fieldset onseeked="go()">Form elements</fieldset>
onseekingThe script to be run when the seeking attribute is set to true indicating that seeking is currently active.

 <!-- Executes go() function -->
<fieldset onseeking="go()">Form elements</fieldset>
onstalledThe script to be run when the browser is unable to continue fetching media data.

 <!-- Executes go() function -->
<fieldset onstalled="go()">Form elements</fieldset>
onsuspendThe script to be run when media data has stopped before being completely loaded.

 <!-- Executes go() function -->
<fieldset onsuspend="go()">Form elements</fieldset>
ontimeupdateThe script to be run when the media resources current playback position has changed.

 <!-- Executes go() function -->
<fieldset ontimeupdate="go()">Form elements</fieldset>
onvolumechangeThe script to be run when the volume has changed or been muted.

 <!-- Executes go() function -->
<fieldset onvolumechange="go()">Form elements</fieldset>
onwaitingThe script to be run when the media resource has paused but is expected to resume.

 <!-- Executes go() function -->
<fieldset onwaiting="go()">Form elements</fieldset>
Mouse
onclickThe script to be run when when a mouse is clicked on an element.

 <!-- Executes go() function -->
<fieldset onclick="go()">Form elements</fieldset>
ondblclickThe script to be run when a mouse is double clicked on an element.

 <!-- Executes go() function -->
<fieldset ondblclick="go()">Form elements</fieldset>
onmousedownThe script to be run when he mouse button is pressed down while the cursor is over an element.

 <!-- Executes go() function -->
<fieldset onmousedown="go()">Form elements</fieldset>
onmousemoveThe script to be run when the mouse button is moved.

 <!-- Executes go() function -->
<fieldset onmousemove="go()">Form elements</fieldset>
onmouseoutThe script to be run when the mouse cursor moves off an element.

 <!-- Executes go() function -->
<fieldset onmouseout="go()">Form elements</fieldset>
onmouseoverThe script to be run when the mouse cursor moves over an element.

 <!-- Executes go() function -->
<fieldset onmouseover="go()">Form elements</fieldset>
onmouseupThe script to be run when the mouse button is released while the cursor is over the element.

 <!-- Executes go() function -->
<fieldset onmouseup="go()">Form elements</fieldset>
onwheelThe script to be run when the mouse wheel rolls up or down over an element.

 <!-- Executes go() function -->
<fieldset onwheel="go()">Form elements</fieldset>
Scroll
onscrollThe script code to be run when the scrollbar of an element is being scrolled.

 <!-- Executes go() function -->
<fieldset onscroll="go()">Form elements</fieldset> 
Window - NONE

Relevant HTML Tutorials

HTML Advanced - Advanced Forms