Delete This Text What is the for attribute? Is this an id...">

How to set HTML tag id?

If I have the following:

             <label for="deletetxt">Delete This Text</label>

What is the for attribute? Is this an identifier?

Assuming I can't set the class for the label element to style the label element, how to set css for this element?

+3
source share
8 answers

Two questions, two answers:

  • What is the 'for' attribute here?

    This is the identifier of the element <input>to which the label belongs. Some browsers will use it to focus on this element <input>when the user clicks on this<LABEL>

  • how to set css for this element?

    and. If you want all CSS shortcut elements:

      label {
         /* your styles */
      }

. , , .

+3

for , . , ...

<label for="SomeTextField" id="SomeLabel">Some text field</label>
<input type="text" id="SomeTextField">

, :

label {
  font-weight: bold;
  color: red;
}

, . , , , , , .

+8

For , ( , ).

- jQuery:
- html $("label:eq(index)")
- html , , , $("label[for='thatid']")

+1

- input/textarea/select, .

id:

<label id="myLabel" for="deletetxt">Delete This Text</label>

/textarea/select , .

<label id="myLabel">Delete This Text <input ... /></label>
+1

HTML Label Tag . , "" , -

<form>
<label for='ford'>Ford Car</label>
<input type="radio" name="fordCar" id="ford" />
</form>

.

0

"for" - , .

, .

<label for="fname" id="lbl-fname">First:</label>
<input type="text" id="fname" />
0

you can set id as well as class http://www.w3schools.com/tags/tag_label.asp

for the parameter "Indicates which form element is attached to the label", therefore, when the user clicks on the shortcut, he focuses on the target input.

0
source

With a razor in Html I do not find a better way to assign a tag identifier, but you can assign an id like this:

@Html.Label("© Integrantes Grupo:",new { @id="TitleIntegrants"} )
0
source

Source: https://habr.com/ru/post/1743084/


All Articles