सुलभता पैटर्न · मीडिया

इमेज के विकल्प

alt टेक्स्ट उन लोगों के लिए तस्वीर की जगह लेता है जो उसे देख नहीं सकते, इसलिए यह तस्वीर के काम पर निर्भर है: उसका वर्णन करें, उसे छोड़ दें, उसकी मंज़िल का नाम दें या उसके शब्द दोहराएँ। यहाँ तस्वीरें इनलाइन एसवीजी हैं, इसलिए aria-label के साथ role="img" alt का काम करता है, और aria-hidden सजावट को चिह्नित करता है।

डब्ल्यूसीएजी मानदंड
6
कीबोर्ड नियम
4
जाँच का तरीक़ा
axe, कीबोर्ड और इंस्पेक्टर

लाइव डेमो

आज़माएँ

इसे माउस, कीबोर्ड या स्क्रीन रीडर से इस्तेमाल करें। साथ का इंस्पेक्टर दिखाता है कि आपके इस्तेमाल के दौरान ब्राउज़र सहायक तकनीक को क्या बताता है: फ़ोकस, स्थिति में बदलाव और घोषणाएँ।

एक तस्वीर, चार काम

हर इमेज को अलग तरह का विकल्प चाहिए। ग़लत वाला आज़माकर सुनें कि क्या बदलता है।

  • जानकारी देने वाली इमेज

    दुकान में उत्पाद की फ़ोटो

    ब्लू पॉटरी केतली

    ₹2,400

    alt="White teapot hand-painted with cobalt-blue flowers"

    स्क्रीन रीडर कहता है

    कोबाल्ट-नीले फूलों से हाथ से रंगी सफ़ेद केतली, इमेज

    सही। वह बताता है जो ख़रीदार को देखना है; नाम नीचे के टेक्स्ट में पहले से है।

  • सजावटी इमेज

    दो अनुच्छेदों के बीच डिवाइडर

    हमारी कहानी

    हर पीस हमारी जयपुर कार्यशाला में हाथ से चाक पर गढ़ा, ग्लेज़ किया और रंगा जाता है।

    हर खेप दो बार पकाई जाती है, ताकि कोबाल्ट चमकीला बना रहे।

    alt=""

    स्क्रीन रीडर कहता है

    कुछ नहीं: डिवाइडर छोड़ दिया जाता है।

    सही। सिर्फ़ सजावट। एसवीजी पर aria-hidden, या img पर alt="", इसे रास्ते से हटाए रखता है।

  • काम करने वाली इमेज

    होम पेज से जुड़ा लोगो

    ₹999 से ऊपर मुफ़्त डिलीवरी

    alt="Neel Pottery home"

    स्क्रीन रीडर कहता है

    नील पॉटरी का होम पेज, लिंक

    सही। लिंक वाली इमेज का नाम इस पर रखा जाता है कि वह कहाँ ले जाती है, न कि वह कैसी दिखती है।

  • टेक्स्ट वाली इमेज

    सेल का बैनर

    दिवाली सेल 30% छूट सभी दीयों पर 2 नवंबर तक

    alt="Diwali sale: 30% off all lamps, until 2 November"

    स्क्रीन रीडर कहता है

    दिवाली सेल: सभी दीयों पर 30% छूट, 2 नवंबर तक, इमेज

    सही। तस्वीर के शब्द दोहराता है, क्योंकि वही उसका मक़सद हैं।

मेरी इमेज को कौन-सा alt चाहिए?

ज़्यादा से ज़्यादा चार प्रश्नों के जवाब दें; सलाह उनके नीचे दिखेगी।

  1. क्या लिंक या बटन के अंदर सिर्फ़ यही इमेज है?

जावास्क्रिप्ट के बिना डेमो उतना ही काम करता है जितना उसका एचटीएमएल; इंस्पेक्टर के लिए जावास्क्रिप्ट चाहिए।

कीबोर्ड

जिन कुंजियों पर यह काम करता है

हर क्रिया पॉइंटर के बिना काम करती है।

कुंजीयह क्या करती है
Tabलोगो लिंक, हर "ग़लत alt आज़माएँ" बटन, और फिर निर्णय वृक्ष के प्रश्नों पर ले जाता है।
EnterयाSpace"ग़लत alt आज़माएँ" पर, उस तस्वीर का alt ग़लत वाले से बदलता है और वापस लाता है, और दिखाता है कि स्क्रीन रीडर क्या कहता है।
Arrow DownयाArrow Upकिसी प्रश्न में हाँ या नहीं चुनता है; अगला प्रश्न या सलाह उसके नीचे दिखती है।
EnterयाSpace"फिर से शुरू करें" पर, हर जवाब मिटाता है और फ़ोकस पहले प्रश्न पर लौटाता है।

स्क्रीन रीडर

यह क्या घोषित करता है

मार्कअप की भूमिकाओं, नामों और स्थितियों से लिखा गया।

कबअपेक्षित घोषणा
पढ़ते हुए उत्पाद की फ़ोटो तक पहुँचनाकोबाल्ट-नीले फूलों से हाथ से रंगी सफ़ेद केतली, इमेज
पढ़ते हुए डिवाइडर तक पहुँचनाकुछ नहीं: इसे छोड़ दिया जाता है
फ़ोकस लोगो लिंक पर पहुँचता हैनील पॉटरी का होम पेज, लिंक
उत्पाद की फ़ोटो पर "ग़लत alt आज़माएँ"ग़लत alt आज़माएँ, टॉगल बटन, दबा हुआ। स्क्रीन रीडर कहता है: teapot-final-v2.jpg, इमेज। ग़लत। alt बिल्कुल न होने पर कई स्क्रीन रीडर फ़ाइल का नाम पढ़कर सुनाते हैं।
ग़लत alt के साथ फ़ोकस लोगो लिंक पर पहुँचता हैलिंक
आख़िरी जवाब सलाह देता हैसलाह: जो मायने रखता है, उसे एक वाक्य में बताएँ। बताएँ कि इमेज में यहाँ के लिए ज़रूरी क्या दिखता है…

ये अपेक्षित घोषणाएँ हैं, रिकॉर्डिंग नहीं। स्क्रीन रीडर और ब्राउज़र के हिसाब से शब्द और क्रम बदलते हैं।

कोड

कोड कॉपी करें

वही फ़ाइलें जिन पर यह डेमो चलता है। स्टाइल एक प्रीफ़िक्स के साथ परोसी जाती हैं जो इस साइट की अपनी स्टाइल को डेमो से दूर रखता है; आप जो कॉपी करते हैं वह मूल है।

मार्कअप

<div class="ap-alt" data-ap-image-alt>
  <div class="ap-alt__intro">
    <h3 class="ap-alt__name">One picture, four jobs</h3>
    <p class="ap-alt__lead">Each image needs a different kind of alternative. Try the wrong one to hear what changes.</p>
  </div>

  <ul class="ap-alt__cases">
    <li class="ap-alt__case" data-alt-case>
      <div class="ap-alt__case-top">
        <h4 class="ap-alt__kind"><span class="ap-alt__num" aria-hidden="true">1</span>Informative image</h4>
        <p class="ap-alt__ctx">A product photo in a shop</p>
      </div>
      <div class="ap-alt__scene">
        <div class="ap-alt__product">
        <svg class="ap-alt__pic" viewBox="0 0 320 190" preserveAspectRatio="xMidYMid slice" role="img" aria-label="White teapot hand-painted with cobalt-blue flowers" data-alt-img data-wrong-label="teapot-final-v2.jpg">
          <defs>
            <linearGradient id="ialt-wall" x1="0" y1="0" x2="0" y2="1"><stop offset="0" stop-color="#F5EBDD"/><stop offset="1" stop-color="#E8D4BD"/></linearGradient>
            <linearGradient id="ialt-glaze" x1="0" y1="0" x2="1" y2="1"><stop offset="0" stop-color="#FFFFFF"/><stop offset="1" stop-color="#D8E1EC"/></linearGradient>
            <g id="ialt-flower"><g fill="#1D4ED8"><ellipse cy="-6" rx="4.6" ry="6"/><ellipse cy="-6" rx="4.6" ry="6" transform="rotate(72)"/><ellipse cy="-6" rx="4.6" ry="6" transform="rotate(144)"/><ellipse cy="-6" rx="4.6" ry="6" transform="rotate(216)"/><ellipse cy="-6" rx="4.6" ry="6" transform="rotate(288)"/></g><circle r="3.4" fill="#F8FAFC"/><circle r="1.8" fill="#0E7490"/></g>
          </defs>
          <rect width="320" height="190" fill="url(#ialt-wall)"/>
          <rect y="150" width="320" height="40" fill="#D6BE9F"/>
          <ellipse cx="164" cy="160" rx="96" ry="9" fill="#4A3426" opacity=".2"/>
          <g transform="translate(160 106) scale(1.18) translate(-160 -106)">
          <path d="M106 92c-32-6-40 48-2 52" fill="none" stroke="#C3CEDB" stroke-width="13" stroke-linecap="round"/>
          <path d="M106 92c-32-6-40 48-2 52" fill="none" stroke="#F8FAFC" stroke-width="8" stroke-linecap="round"/>
          <path d="M206 114c18-2 30-18 40-42l9 4c-8 30-22 50-44 56z" fill="url(#ialt-glaze)" stroke="#C3CEDB" stroke-width="1.5"/>
          <path d="M128 152h66l-7 8h-52z" fill="#C3CEDB"/>
          <path d="M102 112c0-34 26-50 58-50s58 16 58 50c0 26-18 42-58 42s-58-16-58-42z" fill="url(#ialt-glaze)" stroke="#C3CEDB" stroke-width="1.5"/>
          <path d="M107 98c34 11 72 11 106 0" fill="none" stroke="#1E40AF" stroke-width="3"/>
          <path d="M112 138c30 9 66 9 96 0" fill="none" stroke="#1E40AF" stroke-width="2.5"/>
          <path d="M146 118c-8-6-16-4-20 2 8 2 14 2 20-2zM176 112c8-6 16-4 20 2-8 2-14 2-20-2z" fill="#0F766E"/>
          <use href="#ialt-flower" transform="translate(160 119)"/>
          <use href="#ialt-flower" transform="translate(129 122) scale(1.05)"/>
          <use href="#ialt-flower" transform="translate(191 121) scale(.9)"/>
          <ellipse cx="160" cy="64" rx="34" ry="8" fill="#E2E8F0" stroke="#C3CEDB"/>
          <path d="M137 62c5-11 41-11 46 0" fill="#F8FAFC"/>
          <circle cx="160" cy="52" r="7" fill="#1E40AF"/>
          <path d="M120 96c5-14 16-21 28-24" fill="none" stroke="#FFFFFF" stroke-width="5" stroke-linecap="round" opacity=".85"/>
          </g>
        </svg>
        <div class="ap-alt__prodline">
          <p class="ap-alt__prodname">Blue pottery teapot</p>
          <p class="ap-alt__price">₹2,400</p>
        </div>
      </div>
      </div>
      <p class="ap-alt__code"><code data-alt-right>alt="White teapot hand-painted with cobalt-blue flowers"</code><code data-alt-wrong hidden>&lt;img src="teapot-final-v2.jpg"&gt;</code></p>
      <div class="ap-alt__hear">
        <p class="ap-alt__say-k"><svg class="ap-alt__say-icon" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="M11 5 6 9H3v6h3l5 4V5Z"/><path d="M15.5 8.5a5 5 0 0 1 0 7M18.5 5.5a9 9 0 0 1 0 13"/></svg><span>Screen reader says</span></p>
        <p class="ap-alt__speech" data-alt-right>White teapot hand-painted with cobalt-blue flowers, image</p>
        <p class="ap-alt__speech" data-alt-wrong hidden>teapot-final-v2.jpg, image</p>
        <p class="ap-alt__why ap-alt__why--right" data-alt-right><svg class="ap-alt__mark" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="m5 12 5 5L20 7"/></svg><span><strong>Right.</strong> Says what a shopper needs to see; the name is already in the text below.</span></p>
        <p class="ap-alt__why ap-alt__why--wrong" data-alt-wrong hidden><svg class="ap-alt__mark" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="M6 6l12 12M18 6 6 18"/></svg><span><strong>Wrong.</strong> With no alt at all, many screen readers read out the file name.</span></p>
      </div>
      <button type="button" class="ap-btn ap-alt__try" aria-pressed="false" data-alt-try>
        <svg class="ap-btn__icon" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="M4 12a8 8 0 0 1 14-5.3L20 9"/><path d="M20 4v5h-5"/><path d="M20 12a8 8 0 0 1-14 5.3L4 15"/><path d="M4 20v-5h5"/></svg>
        Try the wrong alt
      </button>
    </li>

    <li class="ap-alt__case" data-alt-case>
      <div class="ap-alt__case-top">
        <h4 class="ap-alt__kind"><span class="ap-alt__num" aria-hidden="true">2</span>Decorative image</h4>
        <p class="ap-alt__ctx">A divider between two paragraphs</p>
      </div>
      <div class="ap-alt__scene">
        <div class="ap-alt__article">
          <p class="ap-alt__kicker">Our story</p>
          <p>Every piece is thrown, glazed and painted by hand in our Jaipur workshop.</p>
          <svg class="ap-alt__flourish" viewBox="0 0 240 28" aria-hidden="true" focusable="false" data-alt-img data-wrong-label="Image of a decorative divider">
            <path d="M6 14h74M160 14h74"/>
            <path d="M80 14c10-13 26-13 28 0-2 9-13 9-15 2M160 14c-10-13-26-13-28 0 2 9 13 9 15 2"/>
            <path class="ap-alt__flourish-fill" d="m120 4 9 10-9 10-9-10z"/>
            <circle class="ap-alt__flourish-fill" cx="100" cy="23" r="1.8"/>
            <circle class="ap-alt__flourish-fill" cx="140" cy="23" r="1.8"/>
          </svg>
          <p>Each batch is fired twice, so the cobalt stays bright.</p>
        </div>
      </div>
      <p class="ap-alt__code"><code data-alt-right>alt=""</code><code data-alt-wrong hidden>alt="Image of a decorative divider"</code></p>
      <div class="ap-alt__hear">
        <p class="ap-alt__say-k"><svg class="ap-alt__say-icon" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="M11 5 6 9H3v6h3l5 4V5Z"/><path d="M15.5 8.5a5 5 0 0 1 0 7M18.5 5.5a9 9 0 0 1 0 13"/></svg><span>Screen reader says</span></p>
        <p class="ap-alt__speech" data-alt-right>Nothing: the divider is skipped.</p>
        <p class="ap-alt__speech" data-alt-wrong hidden>Image of a decorative divider, image</p>
        <p class="ap-alt__why ap-alt__why--right" data-alt-right><svg class="ap-alt__mark" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="m5 12 5 5L20 7"/></svg><span><strong>Right.</strong> Pure decoration. aria-hidden on an SVG, or alt="" on an img, keeps it out of the way.</span></p>
        <p class="ap-alt__why ap-alt__why--wrong" data-alt-wrong hidden><svg class="ap-alt__mark" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="M6 6l12 12M18 6 6 18"/></svg><span><strong>Wrong.</strong> Decoration now interrupts the story, and "image" is said twice.</span></p>
      </div>
      <button type="button" class="ap-btn ap-alt__try" aria-pressed="false" data-alt-try>
        <svg class="ap-btn__icon" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="M4 12a8 8 0 0 1 14-5.3L20 9"/><path d="M20 4v5h-5"/><path d="M20 12a8 8 0 0 1-14 5.3L4 15"/><path d="M4 20v-5h5"/></svg>
        Try the wrong alt
      </button>
    </li>

    <li class="ap-alt__case" data-alt-case>
      <div class="ap-alt__case-top">
        <h4 class="ap-alt__kind"><span class="ap-alt__num" aria-hidden="true">3</span>Functional image</h4>
        <p class="ap-alt__ctx">A logo that links to the home page</p>
      </div>
      <div class="ap-alt__scene">
        <div class="ap-alt__site">
          <div class="ap-alt__chrome" aria-hidden="true"><span></span><span></span><span></span></div>
          <div class="ap-alt__header">
            <a class="ap-alt__logo" href="#ialt-home">
              <svg class="ap-alt__logo-art" viewBox="0 0 172 36" role="img" aria-label="Neel Pottery home" data-alt-img data-wrong-label="">
                <path class="ap-alt__logo-pot" d="M6 13h24l-2.6 13.4A7 7 0 0 1 20.5 32h-5a7 7 0 0 1-6.9-5.6Z"/>
                <path class="ap-alt__logo-rim" d="M4 9.5h28v4H4z"/>
                <path class="ap-alt__logo-leaf" d="M18 4c4 0 6 2 6 5.5-4 0-6-2-6-5.5Z"/>
                <text class="ap-alt__logo-word" x="42" y="24.5">Neel Pottery</text>
              </svg>
            </a>
            <p class="ap-alt__deal">Free delivery over ₹999</p>
          </div>
          <div class="ap-alt__skel" aria-hidden="true"><span></span><span></span><span></span></div>
        </div>
      </div>
      <p class="ap-alt__code"><code data-alt-right>alt="Neel Pottery home"</code><code data-alt-wrong hidden>alt=""</code></p>
      <div class="ap-alt__hear">
        <p class="ap-alt__say-k"><svg class="ap-alt__say-icon" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="M11 5 6 9H3v6h3l5 4V5Z"/><path d="M15.5 8.5a5 5 0 0 1 0 7M18.5 5.5a9 9 0 0 1 0 13"/></svg><span>Screen reader says</span></p>
        <p class="ap-alt__speech" data-alt-right>Neel Pottery home, link</p>
        <p class="ap-alt__speech" data-alt-wrong hidden>Link</p>
        <p class="ap-alt__why ap-alt__why--right" data-alt-right><svg class="ap-alt__mark" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="m5 12 5 5L20 7"/></svg><span><strong>Right.</strong> A linked image is named for where it goes, not for how it looks.</span></p>
        <p class="ap-alt__why ap-alt__why--wrong" data-alt-wrong hidden><svg class="ap-alt__mark" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="M6 6l12 12M18 6 6 18"/></svg><span><strong>Wrong.</strong> The link has no name, so people hear only "link", or the web address instead.</span></p>
      </div>
      <button type="button" class="ap-btn ap-alt__try" aria-pressed="false" data-alt-try>
        <svg class="ap-btn__icon" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="M4 12a8 8 0 0 1 14-5.3L20 9"/><path d="M20 4v5h-5"/><path d="M20 12a8 8 0 0 1-14 5.3L4 15"/><path d="M4 20v-5h5"/></svg>
        Try the wrong alt
      </button>
    </li>

    <li class="ap-alt__case" data-alt-case>
      <div class="ap-alt__case-top">
        <h4 class="ap-alt__kind"><span class="ap-alt__num" aria-hidden="true">4</span>Image of text</h4>
        <p class="ap-alt__ctx">A sale banner</p>
      </div>
      <div class="ap-alt__scene">
        <div class="ap-alt__banner">
        <svg class="ap-alt__pic" viewBox="0 0 320 190" role="img" aria-label="Diwali sale: 30% off all lamps, until 2 November" data-alt-img data-wrong-label="Sale banner">
          <defs>
            <linearGradient id="ialt-night" x1="0" y1="0" x2="1" y2="1"><stop offset="0" stop-color="#2E2A78"/><stop offset="1" stop-color="#6D28D9"/></linearGradient>
            <radialGradient id="ialt-glow"><stop offset="0" stop-color="#FDE68A" stop-opacity=".85"/><stop offset="1" stop-color="#FDE68A" stop-opacity="0"/></radialGradient>
          </defs>
          <rect width="320" height="190" fill="url(#ialt-night)"/>
          <g fill="#E0E7FF" opacity=".7"><circle cx="196" cy="26" r="1.6"/><circle cx="292" cy="40" r="1.2"/><circle cx="226" cy="58" r="1"/><circle cx="300" cy="150" r="1.4"/><circle cx="182" cy="164" r="1"/></g>
          <circle cx="254" cy="104" r="62" fill="url(#ialt-glow)"/>
          <path d="M219 126c4 24 66 24 70 0z" fill="#C2410C"/>
          <ellipse cx="254" cy="126" rx="35" ry="6.5" fill="#EA580C"/>
          <g fill="#FDBA74"><circle cx="238" cy="138" r="2"/><circle cx="254" cy="141" r="2"/><circle cx="270" cy="138" r="2"/></g>
          <path d="M254 80c11 15 13 28 0 41-13-13-11-26 0-41z" fill="#FBBF24"/>
          <path d="M254 97c5 8 6 15 0 21-6-6-5-13 0-21z" fill="#FEF3C7"/>
          <g class="ap-alt__banner-type">
            <text x="24" y="50" font-size="13" font-weight="700" letter-spacing="3" fill="#FDE68A">DIWALI SALE</text>
            <text x="21" y="102" font-size="48" font-weight="800" fill="#FFFFFF">30% off</text>
            <text x="24" y="130" font-size="18" font-weight="600" fill="#E0E7FF">all lamps</text>
            <text x="24" y="162" font-size="12.5" fill="#C7D2FE">Until 2 November</text>
          </g>
        </svg>
      </div>
      </div>
      <p class="ap-alt__code"><code data-alt-right>alt="Diwali sale: 30% off all lamps, until 2 November"</code><code data-alt-wrong hidden>alt="Sale banner"</code></p>
      <div class="ap-alt__hear">
        <p class="ap-alt__say-k"><svg class="ap-alt__say-icon" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="M11 5 6 9H3v6h3l5 4V5Z"/><path d="M15.5 8.5a5 5 0 0 1 0 7M18.5 5.5a9 9 0 0 1 0 13"/></svg><span>Screen reader says</span></p>
        <p class="ap-alt__speech" data-alt-right>Diwali sale: 30% off all lamps, until 2 November, image</p>
        <p class="ap-alt__speech" data-alt-wrong hidden>Sale banner, image</p>
        <p class="ap-alt__why ap-alt__why--right" data-alt-right><svg class="ap-alt__mark" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="m5 12 5 5L20 7"/></svg><span><strong>Right.</strong> Repeats the words in the picture, because they are the point of it.</span></p>
        <p class="ap-alt__why ap-alt__why--wrong" data-alt-wrong hidden><svg class="ap-alt__mark" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="M6 6l12 12M18 6 6 18"/></svg><span><strong>Wrong.</strong> The offer and the closing date, the reasons the banner is there, are lost.</span></p>
      </div>
      <button type="button" class="ap-btn ap-alt__try" aria-pressed="false" data-alt-try>
        <svg class="ap-btn__icon" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="M4 12a8 8 0 0 1 14-5.3L20 9"/><path d="M20 4v5h-5"/><path d="M20 12a8 8 0 0 1-14 5.3L4 15"/><path d="M4 20v-5h5"/></svg>
        Try the wrong alt
      </button>
    </li>
  </ul>

  <section class="ap-alt__tree" aria-labelledby="ialt-tree-name" data-alt-tree>
    <div class="ap-alt__tree-top">
      <svg class="ap-alt__tree-icon" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><circle cx="6" cy="5" r="2.5"/><circle cx="6" cy="19" r="2.5"/><circle cx="18" cy="12" r="2.5"/><path d="M6 7.5v9M8.3 6.2C13 7 15.5 8.5 16 10M8.3 17.8c4.7-.8 7.2-2.3 7.7-3.8"/></svg>
      <div>
        <h3 class="ap-alt__name" id="ialt-tree-name">Which alt does my image need?</h3>
        <p class="ap-alt__lead">Answer up to four questions; the advice appears below them.</p>
      </div>
    </div>
    <ol class="ap-alt__qs">
      <li class="ap-alt__q" data-q="link">
        <fieldset class="ap-alt__set">
          <legend class="ap-alt__legend">Is the image the only thing inside a link or a button?</legend>
          <div class="ap-alt__yn">
            <label class="ap-alt__opt"><input type="radio" name="ialt-q-link" value="yes" /><span>Yes</span></label>
            <label class="ap-alt__opt"><input type="radio" name="ialt-q-link" value="no" /><span>No</span></label>
          </div>
        </fieldset>
      </li>
      <li class="ap-alt__q" data-q="text" hidden>
        <fieldset class="ap-alt__set">
          <legend class="ap-alt__legend">Does the image show words that people need to read?</legend>
          <div class="ap-alt__yn">
            <label class="ap-alt__opt"><input type="radio" name="ialt-q-text" value="yes" /><span>Yes</span></label>
            <label class="ap-alt__opt"><input type="radio" name="ialt-q-text" value="no" /><span>No</span></label>
          </div>
        </fieldset>
      </li>
      <li class="ap-alt__q" data-q="near" hidden>
        <fieldset class="ap-alt__set">
          <legend class="ap-alt__legend">Are the same words already on the page as real text?</legend>
          <div class="ap-alt__yn">
            <label class="ap-alt__opt"><input type="radio" name="ialt-q-near" value="yes" /><span>Yes</span></label>
            <label class="ap-alt__opt"><input type="radio" name="ialt-q-near" value="no" /><span>No</span></label>
          </div>
        </fieldset>
      </li>
      <li class="ap-alt__q" data-q="meaning" hidden>
        <fieldset class="ap-alt__set">
          <legend class="ap-alt__legend">Does the image tell people something the text around it does not?</legend>
          <div class="ap-alt__yn">
            <label class="ap-alt__opt"><input type="radio" name="ialt-q-meaning" value="yes" /><span>Yes</span></label>
            <label class="ap-alt__opt"><input type="radio" name="ialt-q-meaning" value="no" /><span>No</span></label>
          </div>
        </fieldset>
      </li>
      <li class="ap-alt__q" data-q="complex" hidden>
        <fieldset class="ap-alt__set">
          <legend class="ap-alt__legend">Is it a chart, diagram or map that needs more than a sentence?</legend>
          <div class="ap-alt__yn">
            <label class="ap-alt__opt"><input type="radio" name="ialt-q-complex" value="yes" /><span>Yes</span></label>
            <label class="ap-alt__opt"><input type="radio" name="ialt-q-complex" value="no" /><span>No</span></label>
          </div>
        </fieldset>
      </li>
    </ol>
    <div class="ap-alt__verdict">
      <div class="ap-alt__answer" data-verdict="function" hidden>
        <p class="ap-alt__answer-k">Advice</p>
        <h4 class="ap-alt__answer-name">Name it for what it does</h4>
        <p class="ap-alt__answer-text">Describe where the link goes or what the button does, not how the picture looks, like the logo above that links home.</p>
        <p class="ap-alt__answer-code"><code>alt="Neel Pottery home"</code></p>
      </div>
      <div class="ap-alt__answer" data-verdict="words" hidden>
        <p class="ap-alt__answer-k">Advice</p>
        <h4 class="ap-alt__answer-name">Put the words in the alt</h4>
        <p class="ap-alt__answer-text">Repeat the text in the image, like the sale banner's offer and date. Better still, make it real text styled with CSS, so it can be resized and translated.</p>
        <p class="ap-alt__answer-code"><code>alt="Diwali sale: 30% off all lamps, until 2 November"</code></p>
      </div>
      <div class="ap-alt__answer" data-verdict="redundant" hidden>
        <p class="ap-alt__answer-k">Advice</p>
        <h4 class="ap-alt__answer-name">Leave the alt empty</h4>
        <p class="ap-alt__answer-text">The words are already on the page, so reading them twice adds nothing. An empty alt tells screen readers to skip the image.</p>
        <p class="ap-alt__answer-code"><code>alt=""</code></p>
      </div>
      <div class="ap-alt__answer" data-verdict="decorative" hidden>
        <p class="ap-alt__answer-k">Advice</p>
        <h4 class="ap-alt__answer-name">Leave the alt empty</h4>
        <p class="ap-alt__answer-text">The image is decoration, like the divider above. alt="" on an img, or aria-hidden="true" on an inline SVG, keeps it out of the way.</p>
        <p class="ap-alt__answer-code"><code>alt=""</code></p>
      </div>
      <div class="ap-alt__answer" data-verdict="describe" hidden>
        <p class="ap-alt__answer-k">Advice</p>
        <h4 class="ap-alt__answer-name">Describe what matters, in a sentence</h4>
        <p class="ap-alt__answer-text">Say what the image shows that matters here, the way you would on the phone. Leave out "image of": screen readers already say it is an image.</p>
        <p class="ap-alt__answer-code"><code>alt="White teapot hand-painted with cobalt-blue flowers"</code></p>
      </div>
      <div class="ap-alt__answer" data-verdict="complex" hidden>
        <p class="ap-alt__answer-k">Advice</p>
        <h4 class="ap-alt__answer-name">A short alt, then a long description</h4>
        <p class="ap-alt__answer-text">Name the chart and its main point in the alt, then give the detail as text or a table beside it, as the Complex image pattern does.</p>
        <p class="ap-alt__answer-code"><code>alt="Bar chart: most of Mumbai's rain falls from June to September"</code></p>
      </div>
    </div>
    <button type="button" class="ap-btn ap-btn--ghost ap-alt__restart" data-alt-restart hidden>
      <svg class="ap-btn__icon" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="M4 12a8 8 0 1 0 2.4-5.7"/><path d="M4 4v4.5h4.5"/></svg>
      Start again
    </button>
  </section>
  <p class="ap-alt__sr" role="status" data-alt-status></p>
</div>

डब्ल्यूसीएजी 2.2

यह किन मानदंडों को पूरा करता है

वे सफलता मानदंड जिनका यह पैटर्न ध्यान रखता है, और कैसे।

  • 1.1.1 गैर-टेक्स्ट सामग्री स्तर A

    हर तस्वीर को उसके काम के मुताबिक़ विकल्प मिलता है: वर्णन, मंज़िल, उसके अपने शब्द, या सजावट के लिए कुछ नहीं।

  • 1.3.1 जानकारी और संबंध स्तर A

    निर्णय वृक्ष का हर प्रश्न एक fieldset है, जिसका legend उसके हाँ और नहीं रेडियो बटन को नाम देता है।

  • 1.4.5 टेक्स्ट की इमेज स्तर AA

    सेल बैनर दिखाता है कि टेक्स्ट वाली इमेज आख़िरी उपाय क्यों हैं, और उसका alt उसमें दिखने वाला हर शब्द रखता है।

  • 2.4.4 लिंक का उद्देश्य (संदर्भ में) स्तर A

    लोगो लिंक को उसका alt, "नील पॉटरी का होम पेज", नाम देता है, इसलिए संदर्भ के बिना भी उसका मक़सद साफ़ है।

  • 4.1.2 नाम, भूमिका, मान स्तर A

    "ग़लत alt आज़माएँ" aria-pressed वाला टॉगल बटन है, इसलिए उसकी स्थिति सिर्फ़ दिखाई नहीं जाती, बोली भी जाती है।

  • 4.1.3 स्टेटस मैसेज स्तर AA

    स्क्रीन रीडर क्या कहेगा, और वृक्ष के अंत की सलाह, फ़ोकस हिलाए बिना एक विनम्र स्टेटस मैसेज में घोषित होते हैं।

उपयोग

इसे कब इस्तेमाल करें

इसे अपनाएँ

  • हर img एलिमेंट, और हर इनलाइन एसवीजी या canvas जो किसी तस्वीर की जगह है।
  • लिंक और बटन के अंदर की तस्वीरें, जहाँ alt ही कंट्रोल का नाम होता है।
  • किसी संपादकीय या प्रोडक्ट टीम के लिए दिशानिर्देश लिखना जो हर दिन इमेज जोड़ती है।

कुछ और इस्तेमाल करें

  • चार्ट, नक्शे और आरेख: छोटा alt काफ़ी नहीं है, इसलिए जटिल इमेज पैटर्न की तरह लंबा विवरण जोड़ें।
  • दिखते लेबल के बगल के आइकन: आइकन छिपाएँ और लेबल को कंट्रोल का नाम देने दें।
  • जो टेक्स्ट असली टेक्स्ट के रूप में रखा जा सकता है: उसे तस्वीर में बनाने की जगह सीएसएस से सजाएँ।

आम विफलताएँ

आमतौर पर यह कहाँ गलत होता है

  • alt एट्रिब्यूट बिल्कुल नहीं

    तब कई स्क्रीन रीडर फ़ाइल का नाम पढ़ते हैं, जैसे "teapot-final-v2.jpg", जो किसी को कुछ नहीं बताता। हर img को alt चाहिए, भले ही वह ख़ाली हो।

  • "इसकी इमेज" या "इसकी तस्वीर"

    स्क्रीन रीडर पहले से "इमेज" कहते हैं, इसलिए ये शब्द दो बार सुनाई देते हैं। सीधे उससे शुरू करें जो तस्वीर दिखाती है।

  • सजावट का वर्णन करना

    वर्णन किया गया बेल-बूटा या स्टॉक फ़ोटो बेवजह सामग्री को बाधित करता है। सजावट को alt="" या aria-hidden मिलता है।

  • लिंक वाली इमेज पर ख़ाली alt

    जब लिंक में सिर्फ़ तस्वीर हो, तो ख़ाली alt लिंक को बिना नाम के छोड़ देता है। बताएँ कि वह कहाँ ले जाता है।

  • ऐसा alt जो तस्वीर का टेक्स्ट छोड़ देता है

    "सेल बैनर" छूट और तारीख़ दोनों छोड़ देता है। अगर शब्द मायने रखते हैं, तो उनकी जगह alt में है।

  • alt और कैप्शन में एक ही टेक्स्ट

    दिखते कैप्शन को हूबहू दोहराने से लोग उसे दो बार सुनते हैं। alt में वह जोड़ें जो कैप्शन नहीं कहता।

नोट्स

इसे बनाना

  • तस्वीर की जगह लेने वाले इनलाइन एसवीजी के लिए, svg एलिमेंट पर role="img" और aria-label लगाएँ; role="img" के बच्चे छिपे रहते हैं, इसलिए उसका अपना टेक्स्ट और आकृतियाँ नहीं पढ़ी जातीं।
  • सजावटी एसवीजी के लिए aria-hidden="true" इस्तेमाल करें; सजावटी img के लिए alt=""। दोनों तस्वीर को दिखने से छिपाए बिना सुलभता ट्री से बाहर कर देते हैं।
  • alt संदर्भ पर निर्भर है: केतली की फ़ोटो डिज़ाइन का वर्णन करती है क्योंकि उत्पाद का नाम पहले से उसके बगल में है। चाय के बारे में किसी पेज पर उसी फ़ोटो को अलग शब्द चाहिए हो सकते हैं।
  • इसे छोटा रखें, आम तौर पर एक वाक्य। अगर किसी तस्वीर को पूरा अनुच्छेद चाहिए, तो वह जटिल इमेज है: उसे छोटा alt और बगल में लंबा विवरण दें।
  • डेमो के "ग़लत alt आज़माएँ" बटन असली मार्कअप बदलते हैं, इसलिए इंस्पेक्टर और आपका स्क्रीन रीडर दोनों ग़लत संस्करण से मिलते हैं।

स्रोत: W3C WAI: alt निर्णय वृक्ष · W3C WAI: इमेज ट्यूटोरियल · एचटीएमएल: इमेज के विकल्प के रूप में टेक्स्ट देने की ज़रूरतें

लाइट और डार्क थीम में, डेस्कटॉप और फ़ोन की चौड़ाई पर axe से और कीबोर्ड से जाँचा गया। अभी हर स्क्रीन रीडर और ब्राउज़र जोड़ी के साथ नहीं परखा गया। सुधार बताएँ