Thuta Learning
HTML
AdvancedWeb Developmentအခြေခံ

Accessibility Basics

HTMLသင်ခန်းစာ 2725 မိနစ်

ဒီခန်းပြီးရင် ဘာတတ်သွားမလဲ

  • WCAG ရဲ့ Perceivable, Operable, Understandable, Robust စည်းမျဉ်း လေးခုကို ဥပမာနဲ့ ရှင်းပြနိုင်ဖို့
  • Informative image နဲ့ decorative image အတွက် alt text ကို မှန်မှန် ရေးနိုင်ဖို့
  • Icon-only button ကို accessible name ပေးနိုင်ပြီး ARIA ကို ဘယ်အချိန် သုံးသင့်လဲ ဆုံးဖြတ်နိုင်ဖို့
  • Page တစ်ခုကို keyboard၊ zoom နဲ့ automated check တို့နဲ့ ကိုယ်တိုင် စစ်နိုင်ဖို့

ရိုးရိုးလေး ရှင်းပြမယ်

ရိုးရိုးလေး ရှင်းရရင်

အဆောက်အအုံ တစ်ခုမှာ လှေကားတစ်ခုတည်း ရှိရင် wheelchair သုံးသူ၊ ကလေးလှည်း တွန်းသူ၊ ခြေထောက် ဒဏ်ရာရထားသူတွေ မဝင်နိုင်ပါဘူး။ ချဉ်းကပ်လမ်း (ramp) ထည့်လိုက်ရင် လူတိုင်း ဝင်နိုင်ပါတယ်။ Web accessibility ဆိုတာ website အတွက် ramp တွေ ထည့်တာပါ။

Screen reader နဲ့ နားထောင်ပြီး web ကို သုံးတဲ့သူ၊ mouse မသုံးနိုင်လို့ keyboard ပဲ သုံးတဲ့သူ၊ စာလုံးကို 200% ချဲ့ကြည့်ရတဲ့သူ၊ နေရောင်အောက်မှာ ဖုန်းကြည့်နေတဲ့သူ အားလုံးဟာ သင့် page ရဲ့ user တွေပါ။ HTML ကို မှန်မှန် ရေးတာက ဒီ ramp တွေရဲ့ အများစုကို အလိုလို ပေးပါတယ်။

Problem → Why → Solution

ပြဿနာ: automated score ၁၀၀ ရပေမယ့် သုံးလို့ မရတဲ့ page

Team တစ်ခုက Lighthouse လို tool နဲ့ စစ်တော့ accessibility score အပြည့် ရပါတယ်။ ဒါပေမယ့် အောက်က code မှာ tool တွေ ဖမ်းလေ့မရှိတဲ့ ပြဿနာ သုံးခု ရှိပါတယ်။ Chart ရဲ့ alt က ရှိပေမယ့် file နာမည်ပဲ ဖြစ်လို့ မမြင်ရတဲ့သူတွေ ဘာမှ မသိရပါဘူး။ Focus outline ကို ဖျက်ထားလို့ keyboard user တွေ ဘယ်နေရာ ရောက်နေလဲ မမြင်ရပါဘူး။ Required field ကို အနီရောင်နဲ့ပဲ ပြထားပါတယ်။

report.html
<style>
  button:focus { outline: none; }   /* keyboard users lose track of focus */
  .required { color: red; }
</style>
<img src="sales-q2-final.png" alt="sales-q2-final.png">
<label for="email" class="required">Email</label>
<input id="email" name="email" type="email">
<button type="button">Download report</button>

ဘာကြောင့် tool က မဖမ်းတာလဲ

Automated tool တွေက "alt attribute ရှိလား"၊ "label ချိတ်ထားလား" လို စက်က ဆုံးဖြတ်လို့ရတဲ့ မေးခွန်းတွေကိုပဲ ဖြေနိုင်ပါတယ်။ Alt text က အဓိပ္ပာယ် ရှိလား၊ focus ကို မြင်ရလား၊ အရောင်မပါဘဲ နားလည်လို့ ရလားဆိုတာကို လူကပဲ ဆုံးဖြတ်နိုင်ပါတယ်။ ဒါကြောင့် tool score က စမှတ်သာ ဖြစ်ပြီး keyboard နဲ့ screen reader နဲ့ ကိုယ်တိုင် စမ်းတာကို အစားမထိုးနိုင်ပါဘူး။

Core concept: POUR နဲ့ HTML အခြေခံ

W3C ရဲ့ Web Content Accessibility Guidelines (WCAG) က accessibility ကို စမ်းသပ်လို့ရတဲ့ success criteria တွေအဖြစ် ရေးထားပါတယ်။ လက်ရှိ version က WCAG 2.2 ဖြစ်ပြီး project အများစုနဲ့ ဥပဒေ စံနှုန်း အများစုက Level AA ကို ပစ်မှတ်ထားပါတယ်။ Criteria အားလုံးက စည်းမျဉ်း လေးခုအောက်မှာ ရှိပြီး အတိုကောက် POUR လို့ မှတ်ပါတယ်။

စည်းမျဉ်းအဓိပ္ပာယ်HTML ဥပမာ
PerceivableContent ကို အာရုံတစ်ခုခုနဲ့ သိနိုင်ရမယ်Image မှာ alt၊ video မှာ caption
OperableMouse မပါဘဲလည်း သုံးနိုင်ရမယ်<button>, <a href>, visible focus
Understandableဖတ်ရ၊ ခန့်မှန်းရ လွယ်ရမယ်<html lang>, label, error စာ
RobustAssistive tech က ဖတ်နိုင်ရမယ်Valid HTML, native element

Alt text ရေးနည်းက image ရဲ့ ရည်ရွယ်ချက်ပေါ် မူတည်ပါတယ်။ အချက်အလက် ပေးတဲ့ image (chart, ဓာတ်ပုံ) မှာ "ပုံ" ဆိုတာကို မဖော်ပြဘဲ image က ပြောချင်တဲ့ အချက်ကို ရေးပါ — "April မှာ အရောင်း 30% တက်တယ်"။ အလှဆင်ဖို့ သက်သက် ဖြစ်တဲ့ image မှာ alt="" (အလွတ်) ထားပါ၊ screen reader က ကျော်သွားပါတယ်။ alt attribute ကို လုံးဝ မထည့်ရင်တော့ screen reader တချို့က file နာမည်ကို ဖတ်ပါတယ်။

Control တိုင်းမှာ accessible name တစ်ခု လိုပါတယ် — button ရဲ့ စာသား၊ input ရဲ့ label၊ image ရဲ့ alt တို့က အဲဒီ name ဖြစ်လာပါတယ်။ <html lang="en"> လို page ရဲ့ ဘာသာစကားကို ကြေညာထားရင် screen reader က မှန်ကန်တဲ့ အသံထွက်နဲ့ ဖတ်ပါတယ်၊ Myanmar page ဆိုရင် lang="my" ပါ။ ဒီအချက်လေးတွေက code တစ်ကြောင်း နှစ်ကြောင်းပဲ ကုန်ပေမယ့် user အတွေ့အကြုံကို လုံးဝ ပြောင်းလဲပေးပါတယ်။

Keyboard ကလည်း အခြေခံပါ။ Interactive ဖြစ်တဲ့ အရာတိုင်းကို Tab နဲ့ ရောက်ပြီး Enter ဒါမှမဟုတ် Space နဲ့ သုံးနိုင်ရပါမယ်၊ focus ရောက်နေတဲ့ နေရာကိုလည်း မြင်ရရပါမယ်။ စာနဲ့ နောက်ခံ contrast က ပုံမှန်စာအတွက် အနည်းဆုံး 4.5:1 ဖြစ်ရပြီး အချက်အလက်ကို အရောင် တစ်ခုတည်းနဲ့ မပြရပါဘူး။ ARIA ကို native HTML နဲ့ မဖြစ်နိုင်တဲ့ နေရာ — ဥပမာ "×" icon တစ်ခုတည်းပါတဲ့ button ကို နာမည်ပေးတာ — မှာပဲ သုံးပါ။

မှတ်ထားရမယ့် ပုံစံ
  1. မမြင်ရရင် သိနိုင်လား (P)
  2. Mouse မပါဘဲ သုံးနိုင်လား (O)
  3. ရှင်းလင်းပြီး ခန့်မှန်းရလား (U)
  4. Native HTML နဲ့ ရေးထားလား (R)

Tool က စမှတ်ပေးပြီး keyboard နဲ့ screen reader က အဖြေမှန်ကို ပြပါတယ်။

အထွေထွေ ပုံစံ

html
<html lang="language-code">
<img src="informative.png" alt="What the image tells the reader">
<img src="decoration.png" alt="">
<button type="button" aria-label="Action name">icon</button>
<label for="field-id">Visible label</label>
<input id="field-id" name="field">
<style>:focus-visible { outline: 3px solid currentColor; }</style>

Page ရဲ့ ဘာသာစကား၊ image နှစ်မျိုးအတွက် alt၊ icon-only button ရဲ့ နာမည်၊ label ချိတ်ထားတဲ့ field နဲ့ မြင်ရတဲ့ focus style — page တိုင်းမှာ လိုအပ်တဲ့ အခြေခံ ငါးခုပါ။

Example: icon button, chart နဲ့ search field

ဒီ code ထဲက element သုံးခုစီက screen reader user တစ်ယောက်ကို ကြားရမယ့် အရာကို ဂရုတစိုက် ပေးထားပါတယ်။ Tab ကို နှိပ်ပြီး button နဲ့ search box ကို focus ရောက်ပုံကိုလည်း ကြည့်ပါ။ ဒါတွေအားလုံးအတွက် JavaScript ဒါမှမဟုတ် CSS အပို တစ်ကြောင်းမှ မလိုတာကိုလည်း သတိထားပါ။

html
<button type="button" aria-label="Close menu">×</button>
<img src="chart.png" alt="Sales increased by 30 percent in April">
<label for="search">Search tutorials</label>
<input id="search" type="search" name="q">

Code ကို တစ်ပိုင်းချင်း ရှင်းပြမယ်

  1. Icon-only button<button type="button" aria-label="Close menu">×</button>

    "×" က မျက်စိနဲ့ မြင်ရင် ရှင်းပေမယ့် screen reader က "times" လို့ ဖတ်နိုင်ပါတယ်။ aria-label က button ရဲ့ accessible name ကို "Close menu" ဖြစ်စေပါတယ် — visible text မရှိတဲ့ ဒီနေရာက ARIA သုံးသင့်တဲ့ နေရာပါ။

  2. Informative altalt="Sales increased by 30 percent in April"

    Chart ရဲ့ အဓိက အချက်ကို ရေးထားလို့ image ကို မမြင်ရတဲ့သူလည်း အချက်အလက် တူတူ ရပါတယ်။ "Chart image" လို ရေးရင် ဘာမှ မသိရပါဘူး။

  3. Label<label for="search">Search tutorials</label>

    for="search" က input ရဲ့ id နဲ့ ကိုက်လို့ search box ရဲ့ နာမည်က "Search tutorials" ဖြစ်ပြီး label ကို click လုပ်ရင်လည်း focus ရောက်ပါတယ်။

  4. Search input<input id="search" type="search" name="q">

    type="search" က searchbox role ပေးပြီး browser တချို့မှာ စာရိုက်ပြီးရင် ဖျက်ဖို့ clear button ပါ ပြပါတယ်။

You should see
"×" ပါတဲ့ ခလုတ်သေးသေး တစ်ခု၊ chart.png ဖိုင် မရှိရင် ကျိုးနေတဲ့ image icon နဲ့ "Sales increased by 30 percent in April" alt စာ၊ "Search tutorials" label နဲ့ search box တစ်ခု ပေါ်ပါတယ်။ Screen reader က ခလုတ်ကို "Close menu, button" လို့ ဖတ်ပါတယ်။

ငါးမိနစ် manual check

1. Keyboard ပဲ သုံး

Mouse ကို ဘေးချပြီး Tab နဲ့ Shift+Tab နဲ့ page တစ်ခုလုံး သွားပါ။ Focus ကို အမြဲ မြင်ရလား၊ အစဉ်က ယုတ္တိရှိလား၊ ပိတ်မိနေတဲ့ နေရာ ရှိလား စစ်ပါ။

2. 200% zoom

Browser ကို 200% zoom လုပ်ပြီး စာတွေ ထပ်နေတာ၊ ဖြတ်ခံရတာ၊ ဘေးဘက်ကို scroll ဆွဲရတာ ရှိလား ကြည့်ပါ။

3. Screen reader smoke test

NVDA (Windows) ဒါမှမဟုတ် VoiceOver (macOS/iOS) ကို ဖွင့်ပြီး heading list နဲ့ landmark list ကို ကြည့်ကာ button နဲ့ field တွေ နာမည် မှန်လား နားထောင်ပါ။

လက်တွေ့ project တွေမှာ

Real project တွေမှာ ဘယ်လို သုံးလဲ

အစိုးရ website တွေ၊ ဘဏ်တွေနဲ့ e-commerce ကုမ္ပဏီ အများအပြားမှာ accessibility က ဥပဒေ လိုအပ်ချက် ဖြစ်ပါတယ်၊ ဥပမာ European Accessibility Act နဲ့ အမေရိကန်ရဲ့ ADA ဆိုင်ရာ အမှုတွေက WCAG AA ကို စံအဖြစ် ကိုးကားလေ့ ရှိပါတယ်။ ဒါကြောင့် team တွေက design review မှာ contrast နဲ့ focus style ကို စစ်ပြီး pull request တိုင်းမှာ axe လို automated check ကို CI ထဲ run ကြပါတယ်။

Automated check အပြင် release တစ်ခု မထုတ်ခင် keyboard နဲ့ screen reader နဲ့ အဓိက user flow (sign up, checkout, search) တွေကို လူကိုယ်တိုင် ဖြတ်သန်းကြည့်ပါတယ်။ Accessibility ပြဿနာကို အစောပိုင်း design အဆင့်မှာ ပြင်ရတာ launch ပြီးမှ ပြင်ရတာထက် အများကြီး သက်သာလို့ "accessibility ကို အဆုံးမှာ ထည့်မယ်" ဆိုတဲ့ စိတ်ကူးက ကုန်ကျစရိတ် အများဆုံး ရွေးချယ်မှု ဖြစ်တတ်ပါတယ်။

Accessibility ကောင်းတဲ့ page တွေက အားလုံးကို အကျိုးပြုပါတယ် — caption တွေက ဆူညံတဲ့ ကားပေါ်မှာ video ကြည့်သူကို ကူညီပြီး contrast ကောင်းတဲ့ စာက နေရောင်အောက်မှာ ဖတ်ရလွယ်ပါတယ်၊ keyboard shortcut တွေက power user တွေကို ပိုမြန်စေပါတယ်။ ရှင်းလင်းတဲ့ label နဲ့ error message တွေက support request တွေကိုလည်း လျော့စေပါတယ်။

အမှားများ

အဖြစ်များတဲ့ အမှားတွေ

1. Focus outline ကို ဖျက်ပစ်တာ

outline: none ကို အစားထိုး style မပေးဘဲ ရေးလိုက်ရင် keyboard user တွေ page ပေါ်မှာ ဘယ်နေရာ ရောက်နေလဲ မသိနိုင်တော့ပါဘူး။ Mouse click အတွက် outline မလိုချင်ရင် :focus-visible နဲ့ keyboard focus မှာပဲ ထင်ရှားတဲ့ outline ပြပါ။

2. Alt text ကို file နာမည် ဒါမှမဟုတ် "image" လို့ ရေးတာ

alt="IMG_2041.jpg" ဒါမှမဟုတ် alt="image" က tool ကို ကျေနပ်စေပေမယ့် user ကို ဘာမှ မပြောပါဘူး။ Screen reader က image ဖြစ်ကြောင်း ကြေညာပြီးသားမို့ "Image of..." လို့ စရေးစရာလည်း မလိုပါဘူး။

3. Native element ရှိလျက်နဲ့ ARIA ကို အပိုထည့်တာ

<button role="button"> ဒါမှမဟုတ် visible text ရှိပြီးသား link ကို ကွဲပြားတဲ့ aria-label ပေးတာက အကျိုးမရှိရုံမက voice control user တွေ မြင်ရတဲ့ စာကို ပြောတဲ့အခါ အလုပ်မလုပ်အောင် လုပ်နိုင်ပါတယ်။ Accessible name က visible text နဲ့ ကိုက်ပါစေ။

Best Practices

အကောင်းဆုံး အလေ့အကျင့်များ

  • <html lang="..."> ကို page တိုင်းမှာ ထည့်ပါ၊ screen reader က အသံထွက်ကို အဲဒါနဲ့ ရွေးပါတယ်။
  • Heading level တွေကို ကျော်မသွားဘဲ outline အစဉ်လိုက် ရေးပါ။
  • Automated check ကို CI ထဲ ထည့်ပြီး manual check ကို release checklist ထဲ ထည့်ပါ။

Mini challenge

Mini challenge: accessible newsletter card

Newsletter sign-up card တစ်ခုကို lesson ထဲက အခြေခံ ငါးခုလုံး ပါအောင် ရေးပါ။ ပြီးရင် mouse မသုံးဘဲ Tab နဲ့ စမ်းပါ။

  • <html lang="en"> နဲ့ card ခေါင်းစဉ် h2 တစ်ခု
  • အလှဆင် wave image က alt=""၊ ဓာတ်ပုံက အချက်အလက် ပေးတဲ့ alt ပါရမယ်
  • Card ကို ပိတ်ဖို့ "×" icon-only button ကို aria-label ပေးရမယ်
  • Email field ကို label နဲ့ ချိတ်ပြီး :focus-visible outline style ထည့်ရမယ်
newsletter.html
<!doctype html>
<html>
<head>
  <meta charset="utf-8">
  <title>Newsletter</title>
  <style>
    /* TODO: a clearly visible keyboard focus style */
  </style>
</head>
<body>
  <!-- TODO: set the page language on <html> -->
  <!-- TODO: close button "×" with an accessible name -->
  <!-- TODO: decorative wave.svg and an informative team photo -->
  <!-- TODO: h2 heading, labelled email field and a subscribe button -->
</body>
</html>

ရလဒ်: Tab နှိပ်ရင် "×" ခလုတ်၊ email field၊ Subscribe ခလုတ်ကို အစဉ်လိုက် ထူထူ outline နဲ့ focus ရောက်ပါတယ်။ Screen reader က "Close newsletter, button" လို့ ဖတ်ပြီး wave image ကို ကျော်ကာ ဓာတ်ပုံရဲ့ alt ကို ဖတ်ပါတယ်။

အရိပ်အမြွက် ကြည့်ရန်

Decorative image ရဲ့ alt ကို လုံးဝ မဖြုတ်ပါနဲ့ — alt="" လို့ အလွတ် ရေးပါ။ :focus-visible က keyboard focus မှာပဲ ပေါ်ပါတယ်။

အဖြေ ကြည့်ရန်
newsletter.html
<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>Newsletter</title>
  <style>
    :focus-visible { outline: 3px solid #1d4ed8; outline-offset: 2px; }
  </style>
</head>
<body>
  <section aria-labelledby="news-title">
    <button type="button" aria-label="Close newsletter"
            onclick="this.parentElement.hidden = true">×</button>
    <img src="wave.svg" alt="">
    <h2 id="news-title">Join our HTML newsletter</h2>
    <img src="team.jpg" alt="Three tutors laughing around a laptop in our Yangon office">
    <form action="/subscribe" method="post">
      <label for="news-email">Email address</label>
      <input id="news-email" name="email" type="email" autocomplete="email" required>
      <button type="submit">Subscribe</button>
    </form>
  </section>
</body>
</html>

Quick Quiz 1 / 3

Section တွေကြား ခွဲဖို့ပဲ သုံးတဲ့ အလှဆင် divider image အတွက် ဘယ် markup က မှန်လဲ။

Quick Quiz 2 / 3

<button type="button">×</button> ကို screen reader user တွေ နားလည်အောင် ဘယ်လို ပြင်မလဲ။

Quick Quiz 3 / 3

Automated audit မှာ accessibility score ၁၀၀ ရပြီးနောက် ဘာလုပ်သင့်လဲ။

မှတ်ထားရမယ့် အချက်များ

  • WCAG 2.2 Level AA က အသုံးများတဲ့ ပစ်မှတ်ဖြစ်ပြီး criteria တွေက POUR စည်းမျဉ်း လေးခုအောက်မှာ ရှိပါတယ်။
  • Informative image မှာ အချက်အလက်ကို ရေးပြီး decorative image မှာ alt="" ထားပါ။
  • Interactive element တိုင်း keyboard နဲ့ သုံးနိုင်ပြီး focus မြင်ရရပါမယ်။
  • ARIA ကို native HTML နဲ့ မဖြစ်နိုင်တဲ့ နေရာမှာပဲ သုံးပြီး tool score ကို manual test နဲ့ ဖြည့်ပါ။

Web Content Accessibility Guidelines (WCAG) 2.2 — W3C

နောက်ဆုံးပြင်ဆင်ရက်

Progress ကို ဤ browser (ဤစက်) တွင်သာ သိမ်းထားပါသည်။ အခြားစက်များနှင့် sync မလုပ်ပါ။

ဤသင်ခန်းစာတွင် အမှားတွေ့ပါက အကြောင်းကြားရန်သင့် email app ကို ဤသင်ခန်းစာလိပ်စာ ဖြည့်ပြီးသားဖြင့် ဖွင့်ပေးပါမည် — သင်ကိုယ်တိုင် ပို့မှသာ ပို့မည်ဖြစ်သည်။

Accessibility Basics | Thuta Learning