Home Web Front-end CSS Tutorial Tutorial on using html label label_Basic tutorial

Tutorial on using html label label_Basic tutorial

May 16, 2016 pm 12:06 PM
html Tutorial Label

In Dreamweaver8, as soon as a form or form object, text box, etc. is added, a will be added to the code. I have never understood what this label does. I just saw the explanation today:
There are two attributes in Label that are very useful, one is FOR and the other is ACCESSKEY.
FOR attribute
Function: Indicates the HTML element to be bound to the Label tag. When you click this tag, the bound element will gain focus.
Usage:

ACCESSKEY attribute:
Function: Indicates access to the element bound to the Label tag When you press the hotkey, the bound element will get focus.
Usage:
Limitations: The shortcut key set by the accessKey attribute cannot be used with the browser's Shortcut keys conflict, otherwise the browser's shortcut keys will be activated first.

Notes
To bind LABEL to another control, set the FOR attribute of the LABEL element to the same ID as the control. Binding LABEL to the control's NAME property is useless. However, to submit the form, you must specify a name for the control to which the LABEL element is bound.
There are two ways to add an underline to the specified shortcut key. The LABEL element's rich text support allows adding U elements on both sides of the shortcut key characters specified by the ACCESSKEY attribute. If you prefer to use style sheets (CSS) to apply styles, you can include the character in SPAN and set the style to "text-decoration: underline".

If the user clicks LABEL, the onclick event on LABEL will be triggered first, and then the onclick event on the control specified by the htmlFor attribute will be triggered. Pressing the shortcut key set by LABEL will set the focus but not trigger the onclick event.

Things to note:
1. Nesting of tags is not allowed.
2. This element is available in HTML and scripts of Internet Explorer 4.0 and above.
3. This element is an inline element.
4. This element requires a closing tag.

Element sample code
The following example uses the LABEL element and the ACCESSKEY attribute to set the focus of the text box.


Demo:


[Ctrl A Select all Note:If you need to introduce external Js, you need to refresh to execute]
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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Table Border in HTML Table Border in HTML Sep 04, 2024 pm 04:49 PM

Guide to Table Border in HTML. Here we discuss multiple ways for defining table-border with examples of the Table Border in HTML.

Nested Table in HTML Nested Table in HTML Sep 04, 2024 pm 04:49 PM

This is a guide to Nested Table in HTML. Here we discuss how to create a table within the table along with the respective examples.

HTML margin-left HTML margin-left Sep 04, 2024 pm 04:48 PM

Guide to HTML margin-left. Here we discuss a brief overview on HTML margin-left and its Examples along with its Code Implementation.

HTML Table Layout HTML Table Layout Sep 04, 2024 pm 04:54 PM

Guide to HTML Table Layout. Here we discuss the Values of HTML Table Layout along with the examples and outputs n detail.

HTML Input Placeholder HTML Input Placeholder Sep 04, 2024 pm 04:54 PM

Guide to HTML Input Placeholder. Here we discuss the Examples of HTML Input Placeholder along with the codes and outputs.

HTML Ordered List HTML Ordered List Sep 04, 2024 pm 04:43 PM

Guide to the HTML Ordered List. Here we also discuss introduction of HTML Ordered list and types along with their example respectively

Moving Text in HTML Moving Text in HTML Sep 04, 2024 pm 04:45 PM

Guide to Moving Text in HTML. Here we discuss an introduction, how marquee tag work with syntax and examples to implement.

HTML onclick Button HTML onclick Button Sep 04, 2024 pm 04:49 PM

Guide to HTML onclick Button. Here we discuss their introduction, working, examples and onclick Event in various events respectively.

See all articles