aria-hidden और aria-live
सजावटी एलिमेंट छिपाएँ और गतिशील सामग्री की घोषणा स्क्रीन रीडर से कराएँ
aria-hidden और aria-live, CoddyKit पर HTML Academy का एक निःशुल्क पाठ है। यह 4 में से 4वाँ पाठ है। इस अध्ययन पथ के 3 तक कोई भी पाठ पूरा पढ़ना निःशुल्क है — इसके बाद CoddyKit PRO हर पाठ अनलॉक करता है, साथ ही अंतर्निर्मित कोड संपादक और चौबीसों घंटे एआई शिक्षक के साथ व्यावहारिक अभ्यास भी उपलब्ध कराता है। यह HTML Academy सीखने के मार्ग का हिस्सा है और आपकी प्रगति वेब तथा CoddyKit ऐप पर सिंक होती रहती है। HTML Academy पाठ्यक्रम में कुल 4 पाठ शामिल हैं।
aria-hidden
aria-hidden="true" किसी तत्व को एक्सेसिबिलिटी ट्री से हटा देता है — स्क्रीन रीडर उसे पूरी तरह छोड़ देते हैं:
<!-- Decorative icon: visible but skip by screen readers -->
<span aria-hidden="true">★★★★☆</span>
<span class="sr-only">4 out of 5 stars</span>
<!-- Decorative separator -->
<img src="divider.svg" alt="" aria-hidden="true">
<!-- Note: aria-hidden does NOT affect visibility or tab focus
A button with aria-hidden is still tabbable! -->aria-hidden के उपयोग
aria-hidden के उपयुक्त उपयोग:
<!-- 1. Icons next to descriptive text -->
<button>
<svg aria-hidden="true"><!-- icon --></svg>
Save Document
</button>
<!-- 2. Repeated text in a card link -->
<a href="/blog/post-1">
<span aria-hidden="true">Read more</span>
<span class="sr-only">Read more: HTML5 Forms Guide</span>
</a>
<!-- 3. UI decoration (dots, decorative borders) -->
<span aria-hidden="true">•••</span>aria-hidden की सामान्य गलती
focus किए जा सकने वाले तत्वों पर aria-hidden कभी लागू न करें:
<!-- BAD: button is in tab order but invisible to screen readers -->
<button aria-hidden="true">Close</button>
<!-- Users reach this via Tab but hear nothing
They cannot tell if they're on a button or lost focus -->
<!-- If you want to hide from both: use hidden attribute -->
<button hidden>Close</button>
<!-- Or: disabled (but disabled removes from tab order) -->
<button disabled aria-hidden="true">Close</button>aria-live
aria-live किसी क्षेत्र को लाइव क्षेत्र में बदल देता है — बदलावों की स्वचालित रूप से घोषणा की जाती है:
<!-- polite: announce when user is idle -->
<div aria-live="polite" id="status"></div>
<!-- assertive: announce immediately, interrupting current speech -->
<div aria-live="assertive" id="errors"></div>
<script>
// Inject text to trigger announcement:
document.getElementById('status').textContent = 'File saved successfully.';
// Screen reader announces this without user moving focus
</script>aria-live के मान
aria-live के तीन मान:
off— डिफ़ॉल्ट: बदलावों की घोषणा नहीं की जातीpolite— उपयोगकर्ता के रुकने पर घोषणा की जाती है; गैर-ज़रूरी अपडेट के लिएassertive— तुरंत घोषणा की जाती है और वर्तमान घोषणा बाधित होती है; errors और महत्वपूर्ण alerts के लिए
aria-atomic
aria-atomic यह नियंत्रित करता है कि पूरे क्षेत्र की घोषणा की जाए या केवल बदले हुए हिस्सों की:
<div aria-live="polite" aria-atomic="true" id="timer">
Time remaining: 05:00
</div>
<!-- aria-atomic="true": announce the whole div each update -->
<!-- Without it: only the changed text node is announced
'Time remaining: 05:00' vs just '05:00' -->
<script>
setInterval(() => {
document.getElementById('timer').textContent = `Time remaining: ${getTime()}`;
}, 1000);
</script>aria-relevant
aria-relevant यह निर्दिष्ट करता है कि किस प्रकार के बदलावों की घोषणा की जाए:
<div
aria-live="polite"
aria-relevant="additions text" <!-- announce added content and text changes -->
id="feed"
>
<!-- New items added here -->
</div>
<!-- Values: additions, removals, text, all
Default: additions text
aria-relevant="removals" needed to announce deleted items -->लाइव क्षेत्रों के लिए सर्वोत्तम तरीके
लाइव क्षेत्रों के लिए दिशानिर्देश:
- हर प्रकार की घोषणा के लिए एक स्थायी लाइव क्षेत्र उपयोग करें (उसे बनाएँ और हटाएँ नहीं)
- शुरुआत में सामग्री खाली रखें; घोषणा शुरू करने के लिए पाठ डालें
- घोषणाओं को संक्षिप्त रखें — स्क्रीन रीडर बाधित हो सकते हैं या पीछे छूट सकते हैं
- लोड होने की स्थिति के लिए: polite का उपयोग करें
- फ़ॉर्म errors के लिए: assertive या role="alert" का उपयोग करें
टोस्ट सूचनाओं के पैटर्न
लाइव क्षेत्रों के साथ टोस्ट सूचनाओं की घोषणा:
<div
role="status"
aria-live="polite"
aria-atomic="true"
id="toast-container"
class="sr-only"
></div>
<script>
function showToast(message) {
const container = document.getElementById('toast-container');
container.textContent = '';
// Force rerender for re-announcement:
requestAnimationFrame(() => {
container.textContent = message;
});
}
</script>aria-busy
aria-busy="true" यह दर्शाता है कि सामग्री अपडेट की जा रही है:
<div id="feed" aria-live="polite" aria-busy="false">
<!-- content -->
</div>
<script>
const feed = document.getElementById('feed');
feed.setAttribute('aria-busy', 'true');
await loadContent();
feed.innerHTML = newContent;
feed.setAttribute('aria-busy', 'false');
// Only now does the live region announce the update
</script>त्वरित जाँच
aria-live="assertive" का उपयोग कब करना चाहिए और polite का कब?
पुनरावृत्ति: aria-hidden और aria-live
छिपाने और लाइव क्षेत्रों की आवश्यक बातें:
aria-hidden="true"— तत्व को एक्सेसिबिलिटी ट्री से हटा देता है (focus किए जा सकने वाले तत्वों पर नहीं!)aria-live="polite"— उपयोगकर्ता के निष्क्रिय होने पर बदलावों की घोषणा करता हैaria-live="assertive"— तुरंत घोषणा करता है (errors के लिए)aria-atomic="true"— बदलाव होने पर पूरे क्षेत्र की घोषणा करता हैaria-busy— लोड होने के दौरान घोषणाओं को रोकता है
एआई शिक्षक के साथ HTML सीखें — निःशुल्क
अपने ब्राउज़र में वास्तविक कोड लिखें और चलाएँ, चौबीसों घंटे एआई शिक्षक से तुरंत सहायता पाएँ, और वेब या ऐप पर वहीं से शुरू करें जहाँ आपने छोड़ा था।
- पाठ्यक्रम
- 40
- पाठ
- 159
अक्सर पूछे जाने वाले प्रश्न
क्या “aria-hidden और aria-live” पाठ निःशुल्क है?
हाँ — HTML Academy अध्ययन पथ के 3 तक कोई भी पाठ, जिसमें “aria-hidden और aria-live” भी शामिल है, यहाँ वेब पर पूरा पढ़ना निःशुल्क है। इसके बाद CoddyKit PRO हर पाठ अनलॉक करता है, साथ ही अंतर्निर्मित कोड संपादक और चौबीसों घंटे एआई शिक्षक के साथ इंटरैक्टिव अभ्यास भी उपलब्ध कराता है। HTML Academy पाठ्यक्रम में कुल 4 पाठ शामिल हैं।
“aria-hidden और aria-live” में मैं क्या सीखूँगा?
सजावटी एलिमेंट छिपाएँ और गतिशील सामग्री की घोषणा स्क्रीन रीडर से कराएँ आप ब्राउज़र में सीधे चलाए जाने वाले व्यावहारिक कोड के साथ HTML Academy का अभ्यास करते हैं, और पाठ पूरा करते समय 24/7 एआई ट्यूटर आपके प्रश्नों के उत्तर देता है।
क्या HTML Academy शुरू करने के लिए मुझे किसी अनुभव की आवश्यकता है?
पहले के अनुभव की आवश्यकता नहीं है। CoddyKit पर HTML Academy शुरुआती से लेकर उन्नत शिक्षार्थियों तक सभी के लिए व्यवस्थित किया गया है, इसलिए आप यहीं से या शुरुआत से सीखना शुरू कर सकते हैं और अपनी गति से आगे बढ़ सकते हैं। यह 4 में से 4वाँ पाठ है।
“aria-hidden और aria-live” पाठ पूरा करने में कितना समय लगता है?
CoddyKit का अधिकांश पाठ लगभग 5–10 मिनट में पूरा हो जाता है। हर पाठ छोटा और संवादात्मक है, इसलिए आप लगातार प्रगति करते हैं और वेब या ऐप पर वहीं से सीखना जारी रख सकते हैं जहाँ आपने छोड़ा था।
क्या मैं इस HTML Academy पाठ में कोड लिख और चला सकता हूँ?
हाँ। हर HTML Academy पाठ में एक अंतर्निर्मित कोड संपादक शामिल है, जिससे आप सीधे अपने ब्राउज़र में वास्तविक कोड लिख और चला सकते हैं और तुरंत एआई प्रतिक्रिया पा सकते हैं—स्थानीय सेटअप की आवश्यकता नहीं है।
इस पाठ्यक्रम के सभी पाठ
- ARIA बनाम मूल HTML का उपयोग कब करें
- role button alert dialog और landmark
- aria-label aria-labelledby और aria-describedby
- aria-hidden और aria-live