html5 Site Icon CSS3 Site Icon CSS Site Icon

HTML4 Reference

HTML <label> tag

Definition

The <label> tag is used to define a label for an <input>, <select> or <textarea> element of a <form>.

Example


<label for="fish">Fish</label>

Required Attributes

NONE

Optional Attributes

for - specifies the form element a label is bound to.

The for attribute must match the id attribute of a form element to bind them together.


<label for="chicken">Fish</label>
<input type="radio" name="pie" value="Chicken" id="chicken" />

Common Attributes

accesskey - specifies a keyboard shortcut to an element.


<label accesskey="aKey">Label text here</label>

class - specifies a classname for the element allowing you to apply the style of the predefined class to the content.


<label class="classname">Label text here</label>

id - specifies a unique id for the element allowing you to apply the style of the predefined id to the content.


<label id="idname">Label text here</label>

style - specifies an inline style for the element allowing you to apply the style to the content.


<label style="color:red;text-align:left">Label text here</label>

title - specifies extra information about the content.


<label title="information about the content">Some text here</label>

Language Attributes

dir - specifies the directional flow of the content.


<!-- The text will flow from left to right -->
<label dir="ltr">Label text here</label>

<!-- The text will flow from right to left -->
<label dir="rtl">Label text here</label>

lang - specifies a language code for the content of the element.


<label lang="en">Label text here</label>

xml:lang - specifies a language code for the content of the element in XHTML documents.


<label xml:lang="fr">Label text here</label>

Document Event Attributes

NONE

Form Event Attributes

onblur - The JavaScript code to be run when an element loses focus.


<!-- Executes the go() function -->
<label onblur="go()">Label text here</label>

onfocus - The JavaScript code to be run when an element gains focus.


<!-- Executes the go() function -->
<label onfocus="go()">Label text here</label>

Image Event Attributes

NONE

Keyboard Event Attributes

onkeydown - The JavaScript code to be run when an element is in focus and keyboard key is pressed.


<!-- Executes the go() function -->
<label onkeydown="go()">Label text here</label>

onkeypress - The JavaScript code to be run when an element is in focus and keyboard key is pressed down and released.


<!-- Executes the go() function -->
<label onkeypress="go()">Label text here</label>

onkeyup - The JavaScript code to be run when an element is in focus and keyboard key is released.


<!-- Executes the go() function -->
<label onkeyup="go()">Label text here</label>

Mouse Event Attributes

onclick - The JavaScript code to be run when a mouse is clicked on the element.


<!-- Executes the go() function -->
<label onclick="go()">Label text here</label>

ondblclick - The JavaScript code to be run when a mouse is double clicked on the element.


<!-- Executes the go() function -->
<label ondblclick="go()">Label text here</label>

onmousedown - The JavaScript code to be run when the mouse button is pressed down while the cursor is over the element.


<!-- Executes the go() function -->
<label onmousedown="go()">Label text here</label>

onmousemove - The JavaScript code to be run when the mouse button is moved.


<!-- Executes the go() function -->
<label onmousemove="go()">Label text here</label>

onmouseout - The JavaScript code to be run when the mouse cursor moves off an element.


<!-- Executes the go() function -->
<label onmouseout="go()">Label text here</label>

onmouseover - The JavaScript code to be run when the mouse cursor moves over an element.


<!-- Executes the go() function -->
<label onmouseover="go()">Label text here</label>

onmouseup - The JavaScript code to be run when the mouse button is released while the cursor is over the element.


<!-- Executes the go() function -->
<label onmouseup="go()">Label text here</label>


<kbd> tag    << Prev          Next >>   <legend> tag

go to home page Homepage go to top of page Top

HTML Elements

The complete set of HTML elements also known as HTML tags from the latest HTML 4.01 Specification.

Click the links for more information on individual tags and their attributes.

<!--...-->

<!DOCTYPE>

<a>

<abbr>

<acronym>

<address>

<applet>

<area />

<b>

<base />

<basefont />

<bdo>

<big>

<blockquote>

<body>

<br />

<button>

<caption>

<center>

<cite>

<code>

<col />

<colgroup>

<dd>

<del>

<dfn>

<dir>

<div>

<dl>

<dt>

<em>

<fieldset>

<font>

<form>

<frame />

<frameset>

<h1> - <h6>

<head>

<hr />

<html>

<i>

<iframe>

<img />

<input />

<ins>

<isindex />

<kbd>

<label>

<legend>

<li>

<link />

<map>

<menu>

<meta />

<noframes>

<noscript>

<object>

<ol>

<optgroup>

<option>

<p>

<param />

<pre>

<q>

<s>

<samp>

<script>

<select>

<small>

<span>

<strike>

<strong>

<style>

<sub>

<sup>

<table>

<tbody>

<td>

<textarea>

<tfoot>

<th>

<thead>

<title>

<tr>

<tt>

<u>

<ul>

<var>