w3resource

HTML label tag and element

1. HTML label element is used to represent information of the associated control.

2. HTML label element starts with a <label> tag and ends with a </label> tag.

Syntax

<label>............</label>

Category

HTML label element belongs to HTML forms.

Whether both start and end tags are required

Yes.

Attributes of select element

for.

Identifiers

id, class.

language information and text direction

lang, dir.

Title

Title.

Style

Style.

Accesskey

accesskey.

Events

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

Supported doctypes

HTML 4.01 strict, HTMl 4.01 transitional, HTML 4.01 frameset.

Example of using HTML label element

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>HTML label tag example - HTML tutorial | w3resource</title>
</head>
<body>
<p>What is your favorite scripting language?</p>
<form name="label_example" action="html-label-tag-example.html" >
<input type="radio" name="language" id="php" />
<label for="php">PHP</label>
<br />
<input type="radio" name="language" id="asp" />
<label for="asp">ASP</label>
<br />
<input type="radio" name="language" id="ror" />
<label for="ror">Ruby On Rails</label>
</form>
</body>
</html>

Result

html label element

View this example in a separate browser window

HTML label example

Previous: HTML select, option and optgroup tag and element
Next: HTML script tag and element

Test your Programming skills with w3resource's quiz.



Become a Patron!

Follow us on Facebook and Twitter for latest update.

It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.

https://w3resource.com/html/label/HTML-label-tag-and-element.php