Home > Web Front-end > Front-end Q&A > How to use html label tag

How to use html label tag

青灯夜游
Release: 2019-05-27 13:28:26
Original
3457 people have browsed it

html The label tag is used to define labels (marks) for input elements; the label element does not present any special effects to the user. However, it improves usability for mouse users; when the user selects the label, the browser automatically shifts focus to the form control associated with the label.

How to use html label tag

#How to use the html label tag?

Function: Define annotations (markers) for input elements.

Note: The label element will not present any special effects to the user. However, it improves usability for mouse users. This control is triggered if you click on the text inside the label element. That is to say, when the user selects the label, the browser will automatically turn the focus to the form control related to the label.

Note: The "for" attribute of the

html label label example 1:

<!DOCTYPE HTML>
<html>
<head>
	<meta charset="UTF-8">
</head>
<body>
<p>请点击文本标记之一,就可以触发相关控件:</p>
<form>
<label for="male">Male</label>
<input type="radio" name="sex" id="male" />
<br />
<label for="female">Female</label>
<input type="radio" name="sex" id="female" />
</form>
</body>
</html>
Copy after login

Rendering:

How to use html label tag

html label label example 2:

<!DOCTYPE HTML>
<html>
<head>
	<meta charset="UTF-8">
</head>
<body>
<p>点击文本,就可以触发相关控件:</p>
<form>
<label for="male">Male</label>
<input type="text" id="male" />
<br />
<label for="female">Female</label>
<input type="text" id="female" />
</form>
</body>
</html>
Copy after login

Rendering:

How to use html label tag

The above is the detailed content of How to use html label tag. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template