label for=id Binding Check

Resolves explicit label for binding from document-order IDs and labelability flags. An explicit for attribute uses the first matching ID; a nonlabelable first match prevents binding to a later duplicate.

Description

An explicit label for attribute binds through an element ID.

An explicit label for attribute binds through an element ID. Duplicate IDs can break the expected association when the first match is not labelable.1

Resolves explicit label for binding from document-order IDs and labelability flags. An explicit for attribute uses the first matching ID; a nonlabelable first match prevents binding to a later duplicate.

When to use label for=id Binding Check

Use this for the following task: Resolves explicit label for binding from document-order IDs and labelability flags. An explicit for attribute uses the first matching ID; a nonlabelable first match prevents binding to a later duplicate.

Prepare the parsed attribute values, element states or ordered local lists requested below. Keep attribute presence separate from value.

How to use label for=id Binding Check and understand its results

  1. Prepare the parsed attribute values, element states or ordered local lists requested below. Keep attribute presence separate from value.
  2. Enter hasFor, forId, elementIds, labelable, implicitLabelableCount using the field table, then run the tool.
  3. Read bound, targetIndex, duplicateId. Interpret flags, units, ordering and placeholder values using the rules below.
  4. Review any reported issue or failed check, correct the supplied values when appropriate, and verify the result in its intended context.
Input fieldMeaningValue type and boundsRequirement
hasForHas ForbooleanRequired
forIdFor Idstring; maximum text length 100000Required
elementIdsElement Idslist of string; minimum entries 0; maximum entries 10000; each entry: string; maximum text length 10000Required
labelableLabelablelist of boolean; minimum entries 0; maximum entries 10000; each entry: booleanRequired
implicitLabelableCountImplicit Labelable Countinteger; minimum 0; maximum 10000Required

Supply element IDs and labelability in document order. Explicit for uses only the first match; an explicit empty for does not bind. Without for, the supplied positive implicit-labelable count establishes binding.2

targetIndex = first matching nonempty forId; bound = target is labelable

This summarizes the declared operation. Units, indexing, inclusivity and exceptional cases are explained in the surrounding text.

Output fieldMeaningValue type
boundBoundboolean
targetIndexTarget Indexinteger
duplicateIdDuplicate Idboolean
json
{
  "input": {
    "hasFor": true,
    "forId": "email",
    "elementIds": [
      "email",
      "email"
    ],
    "labelable": [
      false,
      true
    ],
    "implicitLabelableCount": 0
  },
  "output": {
    "bound": false,
    "targetIndex": 0,
    "duplicateId": true
  }
}

Limitations and assumptions

Indices are zero based and −1 means no explicit target. This does not discover implicit descendants or validate duplicate-ID conformance.

This evaluates supplied local information; it does not fetch a page or run a browser. Malformed requests produce input errors. A successfully evaluated request can still contain false flags, empty result lists or a result outside the supplied threshold; those outcomes have the meanings stated above.

Alternative or Complementary methods

Choose img alt Presence Checker for this operation: Checks whether a parsed img has an alt attribute and whether its value is empty. Empty alternative text can be appropriate for decorative images; this is a presence check only. For a complementary task, use required/readonly/disabled Diff Table for this operation: Resolves required, readonly and disabled flags for an ordinary input type. Effective disabled includes inherited fieldset state supplied by the caller. Submission eligibility concerns disabling only; name, checkedness and submitter selection are separate.

Further background: HTML / accessibility reference: label for=id Binding Check.

References

  1. HTML / accessibility reference: label for=id Binding Check — WHATWG

  2. label for=id Binding Check — tool.io

Similar or alternative tools

  • img alt Presence Checker

    Checks whether a parsed img has an alt attribute and whether its value is empty. Empty alternative text can be appropriate for decorative images; this is a presence check only.

  • required/readonly/disabled Diff Table

    Resolves required, readonly and disabled flags for an ordinary input type. Effective disabled includes inherited fieldset state supplied by the caller. Submission eligibility concerns disabling only; name, checkedness and submitter selection are separate.

Don't forget to set a bookmark for tool.io!
Privacy | Imprint | Cookies