Form Types
♿ Form Accessibility — Sab Ke Liye Form
<label for="name">Name:</label><input id="name" type="text">
Accessible forms sab ke liye kaam karti hain — screen readers use karne wale log, motor disabilities wale jo sirf keyboard use karte hain, cognitive disabilities wale log, mobile pe log. Bina accessibility ke tumhari form duniya ki 15% population ke liye broken hai.
Teen pillars: <label> (input se for/id se connected — screen readers announce karte hain field kya hai), <fieldset>/<legend> (related fields ko group karta hai — radio/checkbox groups mein ye ZARURI hai), aria-describedby (input ko helper text/error messages se link karta hai — screen readers field focus pe description padhte hain).
Auto Stand Analogy: "Naam yahan likho" = label. "Ye sab extra items ek group hain" = fieldset/legend. "Agar number 10 digit nahi hai toh ye message padho" = aria-describedby. Accessibility = auto stand pe har customer ko samajhne ka tareeqa.
Code Example
HTML — Form Accessibility — Sab Ke Liye Form
<!-- ✅ SAHI: label with for/id -->
<label for="name">Full Name:</label>
<input type="text" id="name" name="name" required>
<!-- ❌ GALAT: label wraps input (poora area click hota hai) -->
<label>
Name:
<input type="text">
</label>
<!-- ✅ SAHI: fieldset for radio group -->
<fieldset>
<legend>Biryani Size Choose Karo</legend>
<label>
<input type="radio" name="size" value="small"> Small (₹200)
</label>
<label>
<input type="radio" name="size" value="medium" checked> Medium (₹350)
</label>
<label>
<input type="radio" name="size" value="large"> Large (₹500)
</label>
</fieldset>
<!-- ❌ GALAT: radio bina fieldset -->
<input type="radio" name="size" value="small"> Small
<input type="radio" name="size" value="medium"> Medium
<!-- Screen reader: "radio button" — kaunsa group? kya ke liye hai? -->
<!-- ✅ SAHI: aria-describedby for helper text -->
<input type="tel" id="phone"
aria-describedby="phone-help"
pattern="[6-9][0-9]{9}"
required>
<small id="phone-help">
10 digit mobile number, 6-9 se start
</small>
<!-- ✅ SAHI: aria-describedby for error message -->
<input type="email" id="email"
aria-describedby="email-error"
aria-invalid="true"
required>
<span id="email-error" role="alert">
Sahi email address daalo
</span>
<!-- ✅ SAHI: aria-label for icon-only buttons -->
<button type="submit" aria-label="Order submit karo">
📦
</button>
<!-- ❌ GALAT: icon button bina aria-label -->
<button type="submit">📦</button>
<!-- Screen reader: "button" — kya karta hai? -->
<!-- ✅ SAHI: tabindex for logical tab order -->
<input type="text" id="name" tabindex="1">
<input type="email" id="email" tabindex="2">
<input type="tel" id="phone" tabindex="3">
<button type="submit" tabindex="4">Submit</button>
<!-- ✅ SAHI: autofocus on first field -->
<input type="text" id="name" autofocus
aria-label="Full Name, auto-focused">
<!-- ✅ SAHI: required + aria-required -->
<input type="email" required aria-required="true">
<!-- ✅ SAHI: Visible focus styles -->
<style>
input:focus {
outline: 3px solid #3b82f6;
outline-offset: 2px;
}
input:focus:not(:focus-visible) {
outline: none;
}
input:focus-visible {
outline: 3px solid #3b82f6;
outline-offset: 2px;
}
</style>
<!-- ✅ POORA accessible form example -->
<form>
<fieldset>
<legend>Order Place Karo</legend>
<label for="name">Full Name</label><br>
<input type="text" id="name" required
aria-describedby="name-help">
<small id="name-help">ID ke mutabiq naam</small>
<br><br>
<label for="phone">Phone Number</label><br>
<input type="tel" id="phone"
pattern="[6-9][0-9]{9}"
required
aria-describedby="phone-help">
<small id="phone-help">10 digits, 6-9 se start</small>
<br><br>
<label for="size">Biryani Size</label><br>
<select id="size" required>
<option value="">-- Select --</option>
<option value="small">Small ₹200</option>
<option value="medium">Medium ₹350</option>
<option value="large">Large ₹500</option>
</select>
<br><br>
<label for="notes">Special Instructions</label><br>
<textarea id="notes" rows="3"
aria-describedby="notes-help"></textarea>
<small id="notes-help">Extra masala, less oil, etc.</small>
<br><br>
<button type="submit">Order Place Karo</button>
</fieldset>
</form>for/id connectionLabel ka for = input ka id — label click pe input focus, screen reader label padhta hai<fieldset>/<legend>Related fields ko group karta hai — radio/checkbox groups mein ZARURIaria-describedbyInput ko helper text ya error message se ID se link karta haiaria-invalid="true"Screen reader ko batata hai field mein error hairole="alert"Screen reader turant ye element padhta hai jab ye appear hota haiaria-labelText label un elements ke liye jinke paas visible text nahi (icon buttons)tabindex="1"Keyboard tab order control (usually zaruri nahi, natural order best hai)autofocusPage load pe pehla field auto-focus (sirf EK field pe, ek page pe)aria-required="true"Screen readers ke liye explicit required state (HTML required ke saath):focus-visibleFocus ring sirf keyboard users ke liye dikhao, mouse clicks pe nahioutline-offsetFocus ring aur element border ke beech ka space<small> helper textHelper text input ke TURANT baad rakho jo describe karta hai<select> with labelSelect dropdown ko bhi label for="id" se connect karo<textarea> with labelTextarea ko bhi label chahiye, rows se height set karofieldset on entire formPoore form ko fieldset+legend mein wrap = screen readers ko extra context✅ When to Use
- Har input → label se for/id se connect karo
- Radio/checkbox groups → hamesha fieldset+legend mein wrap karo
- Input ke neeche helper text → aria-describedby
- Error messages → aria-describedby + aria-invalid + role="alert"
- Icon-only buttons → aria-label
- Form ka pehla field → autofocus (ek page pe ek autofocus)
- Required fields → required AUR aria-required dono
- Focus styles → :focus-visible keyboard-only rings ke liye
❌ When NOT to Use
- tabindex > 0 normal elements pe → natural tab order toot jata hai
- Multiple fields pe autofocus → ek page pe sirf EK
- aria-label jab visible text hai → label duplicate ho jayegi
- Title attribute important info ke liye → screen readers reliably padhte nahi
- Placeholder as only label → type karne pe disappear, uske baad koi label nahi
Sabse aasan accessibility win: HAR input ko label se connect karo. Ye ek step 50% form accessibility issues fix karta hai. Test karo: sirf keyboard se form pe tab karo (Tab → Shift+Tab → Enter → Space). Agar bina mouse ke form complete kar sako, accessible hai.