HTMLforall

  HTML | PHP | Forum

HTML <legend> tag

Syntax

<legend> - </legend>

Definition and Usage

The LEGEND element defines a caption for form controls grouped by the FIELDSET element. The LEGEND element must be at the start of a FIELDSET, before any other elements.

Optional Attributes

Attribute Value Description
for id_of_another_field Defines which form element the label is for. Set to an ID of a form element.

Note: If this attribute is not specified, the label is associated with its contents.

Optional Attributes

Attribute Value Description
align top
bottom
left
right
Defines the alignment for contents in the fieldset. Top is default

Standard Attributes

id, class, title, style, dir, lang, xml:lang

For a full description, go to Standard Attributes.

Event Attributes

accesskey, onclick, ondblclick, onmousedown, onmouseup, onmouseover, onmousemove, onmouseout, onkeypress, onkeydown, onkeyup

For a full description, go to Event Attributes.

Example

Source Output
<fieldset>
<legend>Formula 1</legend>
<input type="radio" name="f1" id="car1" />
<label for="car1">Ferrari</label>
<br />
<input type="radio" name="f1" id="car2" />
<label for="car2">Williams</label>
</fieldset>
Formula 1

Home

Learn HTML
HTML Tutorial

HTML Reference
HTML by function
HTML by Alphabet

HTML events
HTML attributes
HTML color names

Top-Level Elements
<!--...-->
<!DOCTYPE> 
<html>
<head>
<body>
<frameset>
Head Elements
<base>
<isindex>
<link>
<meta>
<script>
<style>
<title>
Generic Block-level Elements
<address>
<blockquote>
<center>
<del>
<div>
<h1> to <h6>
<hr>
<ins>
<isindex>
<noscript>
<p>
<pre>
Lists
<dd>
<dir>
<dl>
<dt>
<li>
<menu>
<ol>
<ul>
Tables
<caption>
<col>
<colgroup>
<table>
<tbody>
<td>
<tfoot>
<th>
<thead>
<tr>
Forms
<button>
<fieldset>
<form>
<input>
<label>
<legend>
<option>
<optgroup>
<select>
<textarea>
Special Inline Elements
<a>
<applet>
<area>
<basefont>
<bdo>
<br>
<font>
<iframe>
<img>
<map>
<object>
<param>
<q>
<script>
<span>
<sub>
<sup>
Phrase Elements
<abbr>
<acronym>
<cite>
<code>
<del>
<dfn>
<em>
<ins>
<kbd>
<samp>
<strong>
<var>
Font Style Elements
<b>
<big>
<i>
<s>
<small>
<strike>
<tt>
<u>
Frames
<frame>
<frameset>
<noframes>

 

Copyright 2005-8 Sunilcare.  All Rights Reserved.
Comments or suggestions? Contact us.About us