A <label> gives a form control an accessible name and a larger click target. There are two ways to associate them, and doing so is essential for accessibility.
Metodu 1: for + id (esplicitament)
Email address
A <label> gives a form control an accessible name and a larger click target. There are two ways to associate them, and doing so is essential for accessibility.
for + id (esplicitament)Email address
Il-for tal-label jaqbel mal-id tal-input. Dan jaħdem anke jekk mhumiex ħdejn xulxin fil-markup.
<label>
Email address
<input type="email" />
</label>
L-input huwa nested ġewwa l-label — id mhux meħtieġ.
<label><input type="checkbox" /> I agree to the terms</label>
<!-- clicking the text toggles the checkbox -->
<input placeholder="Email" /> <!-- ❌ disappears on typing, poor contrast, not a label -->
A placeholder tinqarovx meta l-utent jikteb u mhuwiex anunzjat b'mod affidabbli — qatt ma taħdamiex bħala l-unika label.
<input type="search" aria-label="Search products" /> <!-- accessible name, no visible label -->
Uża aria-label (jew aria-labelledby) biss meta label viżibbli verament mhuwiex possibbli.
Labels assoċjati korrettament huma waħda mill-prakitki ta' aċċessibilità l-aktar impattanti għal formoli — jagħtu kull kontroll isem għat-teknoloġija assistiva u jingrandxu targets tat-teklim għal kulħadd.
Ippreferi label <label> veru; irrikorri għal aria-label biss meta meħtieġ, u qatt ma ddependaʻx fuq placeholder bħala label.