Каждый современный человек владеет ноутбуком, но как самому убрать возникающие...
![Пропал звук на ноутбуке — что делать?](https://i0.wp.com/sovets.net/photos/uploads/120/8110495-2razrabotanyi-spetsialnyie-programmyi-kotoryie-testiruyut-audio-drayveryi-soundcheck.jpg)
По своему виду метка ничем не отличается от обычного текста, но благодаря ей пользователь может выбрать элемент формы кликом по тексту, расположенному внутри элемента , а не по самому элементу .
Поддержка браузерамиДа | Да | Да | Да | Да | Да |
for | element_id | Определяеть к какому элементу формы относится текущая метка. |
form | form_id | Определяет форму/формы с которой будет связана метка. В качестве значения атрибута выступает идентификатор элемента ( ). Этот атрибут позволяет размещать метки в произвольном месте конкретного документа, а не только внутри тега . Этот атрибут был удален из спецификации HTML 28 апреля 2016 года , но скрипты имеют доступ только для чтения HTMLLabelElement.form (возвращает форму с которой связана метка, либо "0", если метка не связана с формой). |
Чтобы определить к какому элементу формы относится текущая метка, необходимо использовать атрибут for тега . Значение атрибута for должно соответствовать значению глобального атрибута того элемента формы, к которому будет относится метка. Атрибут for можно не использовать, если элемент будет находиться внутри элемента .
Рассмотрим пример использования:
Пример использования тега Да НетВ этом примере мы:
Disclosure: Your support helps keep the site running! We earn a referral fee for some of the services we recommend on this page. Learn more
Sharing is caring!
Element of What does What Does In HTML: Easy Tutorial With Code Example do? The element is used to associate a text label with a form field. The label is used to tell users the value that should be entered in the associated input field. Display inline Code Example Favorite AnimalFor a to work properly, it must include a for attribute, which identifies the to which it is associated. The for attribute"s value should match the id (not the name) of the element.
(Form submission relies on name and label pairing relies on id . This is why you will often see elements with the same value in both attributes. And if the is a checkbox , you might see the same value in the value attribute, and as the content of the element.)
First Name
Agree
Do you agree to the terms and conditions?
Labels and UsabilityIt is, of course, possible to not use the element, and just put unmarked text over or next to a form field. But this isn"t a good idea. Having a paired label is more than just good semantics, it is good usability. With a properly marked-up label, the user can click (or finger-tap) the label in order to bring focus to the element or select it. This is moderately helpful on regular desktop and laptop computers, but on touchscreen mobile phones, it makes a huge difference.
Click this label to select.
",
...);
Тут в строки с соответствующим экранированием записываются id пользователя и referer , который пришел на сервер. И, если в user.id вряд ли будет что-то кроме цифр, то в referer злоумышленник может запихнуть что угодно.
Но на закрывающем теге приколы не заканчиваются. Опасность представляет и открывающий тег , если перед ним в любом месте есть символы [