ရိုးရိုးလေး ရှင်းပြမယ်
ရိုးရိုးလေး ရှင်းရရင်
ဘောလုံးကစားသမားတစ်ယောက်က ဘောပို့တာ၊ ဘောဖမ်းတာ၊ ဂိုးသွင်းတာကို တစ်ခုချင်း လေ့ကျင့်ပြီးရင် ပွဲစမ်းကစားရပါတယ်။ ပွဲထဲမှာမှ ဘယ်အချိန် ဘာသုံးရမလဲဆိုတဲ့ ဆုံးဖြတ်ချက်တွေကို သင်ယူရလို့ပါ။ ဒီ lesson က HTML ရဲ့ ပွဲစမ်းပါ။
Tag အသစ် မသင်ပါဘူး။ Heading၊ paragraph၊ list၊ link၊ image တွေကို စာမျက်နှာ တစ်ခုတည်းမှာ စုသုံးရင်း "ဒီစာကြောင်းက paragraph လား list လား"၊ "ဒီစကားလုံးကို strong လုပ်မလား em လုပ်မလား" ဆိုတဲ့ ဆုံးဖြတ်ချက်တွေကို ကိုယ်တိုင် ချရပါမယ်။
Problem → Why → Solution
ပြဿနာ: မြင်ရတာ မှန်ပေမယ့် structure မရှိ
Tag တစ်ခုချင်း သိပြီဆိုတဲ့ learner တွေ ပထမဆုံး page ရေးရင် အောက်ကလို code မျိုး ထွက်လာတတ်ပါတယ်။ ခေါင်းစဉ်ကို ကြီးကြီးမြင်ရဖို့ b tag နဲ့ br တွေ သုံးထားပြီး list ကို "- " နဲ့ လက်ရေးထားပါတယ်။ Nested list ကိုလည်း li အပြင်ဘက်မှာ ထည့်ထားပါတယ်။
Browser က ဒါကို ပြနိုင်ပါတယ်၊ ဒါပေမယ့် screen reader က heading မရှိလို့ ခုန်ကြည့်စရာ မရှိ၊ list item ဘယ်နှခု ရှိလဲ မပြောနိုင်ပါဘူး။ Search engine ကလည်း page ရဲ့ အဓိကအကြောင်းကို မသိနိုင်ပါဘူး။ ပုံမှာ alt မရှိလို့ ပုံ load မဖြစ်ရင် ဘာမှ မကျန်ပါဘူး။
<body>
<b>Tea Leaf Salad</b><br><br>
- tea leaves<br>
- crunchy mix<br>
<ul>
<li>Steps</li>
<ul><li>Slice the tomato</li></ul>
</ul>
<a href="https://en.wikipedia.org/wiki/Lahpet">click</a>
<img src="salad.jpg">
</body>ဘာကြောင့် ဒါက ပြဿနာလဲ
HTML ရဲ့ အလုပ်က content ရဲ့ အဓိပ္ပာယ်ကို ဖော်ပြဖို့ပါ၊ ပုံစံကို CSS က ယူပါတယ်။ b နဲ့ br က "ဒါ ခေါင်းစဉ်ပါ"၊ "ဒါ list ပါ" လို့ မပြောပါဘူး။ Element မှန်ကို ရွေးလိုက်ရင် screen reader၊ search engine၊ reader mode နဲ့ နောက်ပိုင်း ရေးမယ့် CSS အားလုံး page ကို နားလည်သွားပါတယ်။
Core concept: outline အရင်၊ markup နောက်မှ
Page ကောင်းတစ်ခုကို editor ထဲမှာ တန်းမရေးပါဘူး။ Content ကို စာရွက်ပေါ်မှာ အကြမ်းချပြီး အပိုင်းတစ်ခုစီက ဘာလဲဆိုတာ ဆုံးဖြတ်ပြီးမှ tag ရွေးပါတယ်။ ဒီလေ့ကျင့်ခန်းအတွက် ဆုံးဖြတ်ချက် လေးခု ချပါမယ်။
၁။ Outline ရေးပါ
Page တစ်ခုလုံးကို ဖော်ပြတဲ့ ခေါင်းစဉ်က h1 ဖြစ်ပြီး အပိုင်းတွေက h2 ဖြစ်ပါတယ်။ Recipe မှာဆိုရင် "Lahpet Thoke" က h1၊ "Ingredients" နဲ့ "Steps" က h2 ပါ။ Heading တွေကိုပဲ ဖတ်ကြည့်ရင် page ရဲ့ မာတိကာ ဖြစ်နေရပါမယ်။
၂။ Paragraph လား list လား
ဆက်စပ်နေတဲ့ စာကြောင်းတွေက paragraph ဖြစ်ပြီး သီးခြား item တွေကို စာရင်းလုပ်ရင် list ပါ။ အစဉ်လိုက်လုပ်ရမယ့် အဆင့်တွေ (ချက်ပြုတ်နည်း) ဆိုရင် ol၊ အစဉ်မအရေးကြီးရင် (ပါဝင်ပစ္စည်း) ul ကို သုံးပါ။ Item တစ်ခုကို ထပ်ခွဲချင်ရင် nested list ကို အဲဒီ li ရဲ့ အထဲမှာ ထည့်ရပါမယ်။
၃။ Emphasis ကို အဓိပ္ပာယ်နဲ့ ရွေးပါ
strong က "ဒါ အရေးကြီးတယ်" လို့ ပြောပြီး em က အသံထွက်ဖတ်ရင် ဖိပြောရမယ့် စကားလုံးကို ပြပါတယ်။ Bold ဒါမှမဟုတ် italic ပုံစံ လိုချင်ရုံသက်သက်ဆိုရင် CSS ကို သုံးပါ။
၄။ Link နဲ့ image ကို အဆုံးသတ်ပါ
Link စာသားက ဘယ်ကို သွားမလဲ ပြောရပါမယ်။ target="_blank" က new tab မှာ ဖွင့်ပြီး rel="noopener" က ဖွင့်လိုက်တဲ့ page ကို ကိုယ့် page ကို window.opener ကနေ ထိန်းချုပ်ခွင့် မပေးပါဘူး။ Image မှာ alt နဲ့ width၊ height ထည့်ရင် ပုံ load မဖြစ်ခင် နေရာကြို ချန်ထားလို့ စာတွေ ခုန်မသွားပါဘူး။
| Content | Element |
|---|---|
| အစဉ်လိုက် လုပ်ရမယ့် အဆင့်တွေ | ol + li |
| အစဉ်မအရေးကြီးတဲ့ item တွေ | ul + li |
| အရေးကြီးတဲ့ သတိပေးချက် | strong |
| ဖိပြောရမယ့် စကားလုံး | em |
Whitespace ကို browser က ချုံ့ပါတယ်
Code ထဲမှာ paragraph တစ်ပိုဒ်ကို line နှစ်ကြောင်း ခွဲရေးထားရင်လည်း browser က line break နဲ့ space တွေကို space တစ်ခုအဖြစ် ချုံ့ပြီး စာကြောင်းဆက်အဖြစ် ပြပါတယ်။ ဒါကြောင့် code ကို ဖတ်ရလွယ်အောင် ခွဲရေးလို့ရပြီး line အသစ် တကယ်လိုချင်ရင်တော့ p အသစ် ဒါမှမဟုတ် br ကို သုံးရပါတယ်။
- h1 က စာအုပ်ခေါင်းစဉ်
- h2 တွေက အခန်းတွေ
- p နဲ့ list တွေက အခန်းထဲက စာ
- Link နဲ့ ပုံက ကိုးကားချက်နဲ့ ပုံ
CSS ကို ပိတ်ထားရင်တောင် page ကို အပေါ်ကနေ အောက်ကို ဖတ်ရင် နားလည်ရပါမယ်။ ဒါက structure မှန်မမှန် စစ်တဲ့ အလွယ်ဆုံး test ပါ။
အခြေခံ ပုံစံ
<h1>Page title</h1>
<p>Intro with <strong>key fact</strong> and <em>stressed word</em>.</p>
<h2>Section</h2>
<ul>
<li>Item <ul><li>Sub-item</li></ul></li>
</ul>
<ol><li>First step</li><li>Second step</li></ol>
<a href="https://site.example/page" target="_blank" rel="noopener">Where it goes</a>
<img src="file.jpg" alt="What the image shows" width="W" height="H">Heading တွေက outline၊ paragraph နဲ့ list တွေက content၊ link နဲ့ image က အပြင် resource တွေပါ။ Nested list က li ရဲ့ အထဲမှာ ရှိနေတာကို သတိထားပါ။
နမူနာ အဖြေ: tea leaf salad recipe page
ဒီ page က exercise ရဲ့ task လေးခုကို recipe content နဲ့ ဖြေပြထားတာပါ။ Task 1 က document shell၊ Task 2 က h1 နဲ့ strong/em ပါတဲ့ paragraph နှစ်ပိုဒ်၊ Task 3 က nested ul နဲ့ ol၊ Task 4 က new tab link နဲ့ image ပါ။ Challenge မှာ ဒီ pattern တွေကို content အသစ်နဲ့ ကိုယ်တိုင် ပြန်ရေးရမှာမို့ ဘာကြောင့် ဒီ tag ကို ရွေးလဲ ဆိုတာကို အဓိက ကြည့်ပါ။
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Lahpet Thoke (Tea Leaf Salad) Recipe</title>
</head>
<body>
<h1>Lahpet Thoke: Tea Leaf Salad</h1>
<p>This salad mixes <strong>fermented tea leaves</strong> with crunchy beans,
peanuts and fresh tomato. It is a favourite snack to offer guests.</p>
<p>The leaves taste <em>sour and slightly bitter</em>, so add them
a little at a time.</p>
<h2>Ingredients</h2>
<ul>
<li>2 tablespoons fermented tea leaves</li>
<li>Crunchy mix
<ul>
<li>fried broad beans</li>
<li>roasted peanuts</li>
<li>toasted sesame seeds</li>
</ul>
</li>
<li>1 tomato and a wedge of cabbage</li>
</ul>
<h2>Steps</h2>
<ol>
<li>Slice the tomato and cabbage thinly.</li>
<li>Mix in the tea leaves and a squeeze of lime.</li>
<li>Add the crunchy mix just before serving.</li>
</ol>
<p>Read the history of
<a href="https://en.wikipedia.org/wiki/Lahpet" target="_blank" rel="noopener">lahpet
on Wikipedia</a>.</p>
<img src="lahpet-thoke.jpg" width="600" height="400"
alt="Tea leaf salad on a plate, topped with peanuts and fried beans">
</body>
</html>Code ကို တစ်ပိုင်းချင်း ရှင်းပြမယ်
- Key fact
<strong>fermented tea leaves</strong>Salad ရဲ့ အဓိကပါဝင်ပစ္စည်းဖြစ်လို့ "အရေးကြီးတယ်" ဆိုတဲ့ အဓိပ္ပာယ်နဲ့ strong ကို သုံးပါတယ်။ Default style က bold ဖြစ်ပါတယ်။
- Stress emphasis
<em>sour and slightly bitter</em>အသံထွက်ဖတ်ရင် ဖိပြောမယ့် အပိုင်းဖြစ်လို့ em ပါ။ Screen reader အချို့က em ကို အသံ ပြောင်းဖတ်နိုင်ပေမယ့် အားလုံး မဟုတ်ပါဘူး။ Default style က italic ပါ။
- Nested list inside li
<li>Crunchy mixSub-list ရဲ့ ul က ဒီ li ရဲ့ closing tag </li> မတိုင်ခင် အထဲမှာ ရှိပါတယ်။ ul ရဲ့ တိုက်ရိုက် child အဖြစ် li ပဲ ခွင့်ပြုလို့ ul နောက်မှာ ul တန်းထည့်ရင် invalid ဖြစ်ပါတယ်။
- Ordered steps
<ol>Tomato လှီးပြီးမှ ရောရ၊ ပြီးမှ crunchy mix ထည့်ရလို့ အစဉ်က အဓိပ္ပာယ်ရှိပါတယ်။ ဒါကြောင့် browser က 1၊ 2၊ 3 နံပါတ်တပ်ပေးတဲ့ ol ကို သုံးပါတယ်။
- Safe new-tab link
<a href="https://en.wikipedia.org/wiki/Lahpet" target="_blank" rel="noopener">lahpetLink စာသားက "lahpet on Wikipedia" ဖြစ်လို့ ဘယ်ကိုသွားမလဲ ရှင်းပါတယ်။ ခေတ်မီ browser တွေက target="_blank" ကို noopener အဖြစ် default ယူပြီးသား ဖြစ်ပေမယ့် rel="noopener" ကို ရေးထားတာက ရည်ရွယ်ချက်ကို ရှင်းစေပြီး browser အဟောင်းတွေကိုပါ ကာကွယ်ပါတယ်။
- Image with reserved space
<img src="lahpet-thoke.jpg" width="600" height="400"width နဲ့ height က ပုံ download မပြီးခင် browser ကို နေရာ ကြိုချန်ခိုင်းပါတယ်။ ပုံ မရရင် alt စာသားကို ပြပြီး screen reader ကလည်း အဲဒီစာသားကို ဖတ်ပါတယ်။
"Lahpet Thoke: Tea Leaf Salad" ခေါင်းစဉ်ကြီးအောက်မှာ paragraph နှစ်ပိုဒ် ("fermented tea leaves" က bold၊ "sour and slightly bitter" က italic) ပေါ်ပါတယ်။ Ingredients အောက်မှာ အစက်ပါတဲ့ list နဲ့ ဝိုင်းအလွတ် bullet ပါတဲ့ အတွင်းဘက်ဝင်နေတဲ့ sub-list၊ Steps အောက်မှာ 1. 2. 3. နံပါတ်တပ် list၊ new tab မှာ ဖွင့်တဲ့ link တစ်ခုနဲ့ 600x400 ပုံ (file မရှိရင် broken-image icon နဲ့ alt စာသား) ပေါ်ပါတယ်။Done မပြောခင် ကိုယ့်ကိုယ်ကို စစ်ပါ
ဒီ lesson မှာ အဖြေ code တစ်ခု ပါပေမယ့် ကိုယ့် page က အဖြေနဲ့ စာလုံးတိုင်း တူစရာ မလိုပါဘူး။ အရေးကြီးတာက structure မှန်မမှန်ပါ။ Browser တစ်ခုတည်းနဲ့ ကိုယ့်ဘာသာ စစ်လို့ရတဲ့ အဆင့်လေးခု ရှိပါတယ်။
၁။ Validator ကို ဖြတ်ပါ
validator.w3.org/nu မှာ file ကို upload လုပ်ပါ။ li အပြင်က nested list၊ ပိတ်မထားတဲ့ tag၊ alt မပါတဲ့ ပုံ စတာတွေ ချက်ချင်း ပေါ်လာပါမယ်။
၂။ Heading တွေကိုပဲ ဖတ်ပါ
h1 နဲ့ h2 တွေကိုပဲ အစဉ်လိုက် ဖတ်ကြည့်ရင် page ရဲ့ မာတိကာ ဖြစ်နေလား စစ်ပါ။
၃။ Tab key နဲ့ link ကို ရောက်ပါ
Tab နှိပ်ပြီး link ကို focus ရောက်အောင်လုပ်ကာ Enter နှိပ်ပါ။ New tab ပွင့်ပြီး မူလ page က မပြောင်းရပါဘူး။
၄။ ပုံကို ယာယီ ဖျက်ကြည့်ပါ
src ထဲက file နာမည်ကို တစ်လုံး ပြောင်းပြီး reload လုပ်ပါ။ ပုံနေရာမှာ broken-image icon သေးသေးလေးနဲ့ alt စာသား ပေါ်လာရပါမယ်။ alt ကို ဖတ်ရုံနဲ့ ပုံက ဘာလဲ သိရရင် alt ကောင်းပါတယ်။
လက်တွေ့ project တွေမှာ
လက်တွေ့ project တွေမှာ
Blog post၊ documentation page၊ recipe site၊ news article တွေ အားလုံး ဒီလေ့ကျင့်ခန်းထဲက element လေးငါးမျိုးနဲ့ပဲ ဆောက်ထားတာပါ။ Content management system တွေမှာ writer တွေက editor ထဲမှာ "Heading 2"၊ "Bulleted list" ကို ရွေးလိုက်တာနဲ့ နောက်ကွယ်မှာ h2 နဲ့ ul ထွက်လာပါတယ်။ Developer က ဒီ element တွေကို နားလည်မှ CSS ကို မှန်မှန်ကန်ကန် ရေးနိုင်ပါတယ်။
Recipe site တွေက structure ကို အထူးဂရုစိုက်ပါတယ်။ Ingredient နဲ့ step တွေကို list အစစ်နဲ့ ရေးထားရင် browser reader mode၊ voice assistant နဲ့ search engine တွေက သုံးရလွယ်ပါတယ်။ Team review မှာ "CSS ပိတ်ပြီး ဖတ်ကြည့်"၊ "Tab နဲ့ link တွေကို ဖြတ်သွားကြည့်"၊ "ပုံ file နာမည်ကို ယာယီ မှားပေးပြီး alt ပေါ်မပေါ် ကြည့်" ဆိုတဲ့ check သုံးခုကို မကြာခဏ လုပ်ကြပါတယ်။
အမှားများ
ဖြစ်လေ့ရှိတဲ့ အမှားများ
Nested list ကို li အပြင်မှာ ထည့်တာ
<ul><li>Fruits</li><ul>...</ul></ul> လို ရေးရင် browser က ပြပေးပေမယ့် validator က error ပြပြီး screen reader က sub-list ကို ဘယ် item နဲ့ ဆိုင်လဲ မသိပါဘူး။ </li> ကို sub-list ပြီးမှ ပိတ်ပါ။
Heading ကို style အတွက် ရွေးတာ
"Ingredients" ကို စာလုံးသေးချင်လို့ h4 နဲ့ ရေးတာ၊ စာကြောင်းတစ်ကြောင်းကို ကြီးကြီးမြင်ချင်လို့ h1 နောက်တစ်ခု ထည့်တာက outline ကို ပျက်စေပါတယ်။ Level ကို အရေးပါမှုနဲ့ ရွေးပြီး အရွယ်အစားကို CSS နဲ့ ပြင်ပါ။
"click here" link နဲ့ alt မပါတဲ့ ပုံ
Screen reader user တွေက page ထဲက link အားလုံးကို စာရင်းအဖြစ် ခေါ်ကြည့်လေ့ရှိပါတယ်။ "click here" ငါးခု ပါနေရင် ဘယ်ဟာ ဘယ်ကိုသွားလဲ မသိနိုင်ပါဘူး။ alt မပါတဲ့ ပုံကိုလည်း file နာမည် "IMG_2034.jpg" လို့ ဖတ်ပြတတ်ပါတယ်။
Mini challenge
ကိုယ့်မြို့အတွက် one-day guide page
ကိုယ်နှစ်သက်တဲ့ မြို့တစ်မြို့ (ဥပမာ Bagan) အတွက် "တစ်ရက်တည်း လည်ပတ်နည်း" page တစ်ခုကို original task လေးခုနဲ့ အညီ ရေးပါ။ Recipe example ကို copy မကူးဘဲ content အသစ်နဲ့ structure ကို ကိုယ်တိုင် ဆုံးဖြတ်ပါ။
- Task 1: doctype၊ lang၊ charset၊ viewport၊ title ပါတဲ့ document အပြည့်
- Task 2: h1 တစ်ခုနဲ့ strong နဲ့ em ကို အဓိပ္ပာယ်ရှိရှိ သုံးထားတဲ့ paragraph နှစ်ပိုဒ်
- Task 3: ပစ္စည်းစာရင်းအတွက် ul (nested list တစ်ခုပါ) နဲ့ အချိန်ဇယားအတွက် ol
- Task 4: target="_blank" rel="noopener" ပါတဲ့ link နဲ့ alt၊ width၊ height ပါတဲ့ image
<!DOCTYPE html>
<html lang="en">
<head>
<!-- TODO (Task 1): charset, viewport, a title naming the town -->
</head>
<body>
<!-- TODO (Task 2): h1, then two paragraphs using strong and em -->
<!-- TODO (Task 3): h2 "What to pack" + ul with one nested list -->
<!-- TODO (Task 3): h2 "Plan for the day" + ol in time order -->
<!-- TODO (Task 4): link that opens in a new tab, with rel="noopener" -->
<!-- TODO (Task 4): img with alt, width and height -->
</body>
</html>ရလဒ်: Browser မှာ h1 တစ်ခု၊ h2 နှစ်ခု၊ bold နဲ့ italic စာလုံးပါတဲ့ paragraph နှစ်ပိုဒ်၊ အတွင်းဝင်နေတဲ့ sub-list ပါတဲ့ bullet list၊ နံပါတ်တပ် list၊ new tab မှာ ဖွင့်တဲ့ link နဲ့ ပုံ (ဒါမှမဟုတ် alt စာသား) ပေါ်ပါတယ်။ CSS မပါဘဲ ဖတ်ရင်လည်း နားလည်ရပါမယ်။
အရိပ်အမြွက် ကြည့်ရန်
Code မရေးခင် heading သုံးလေးခုကိုပဲ စာရွက်ပေါ်မှာ ချရေးကြည့်ပါ။ အချိန်ဇယားက နံနက်ကနေ ညနေအထိ အစဉ်ရှိလို့ ol ဖြစ်ပြီး ယူသွားရမယ့် ပစ္စည်းတွေက အစဉ်မရှိလို့ ul ဖြစ်ပါတယ်။
အဖြေ ကြည့်ရန်
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>One Day in Bagan: A Simple Plan</title>
</head>
<body>
<h1>One Day in Bagan</h1>
<p>Bagan has <strong>thousands of ancient temples</strong> spread across a wide plain,
so a plan saves you hours of riding in the heat.</p>
<p>Start <em>before</em> sunrise: the light is softest and the roads are quiet.</p>
<h2>What to pack</h2>
<ul>
<li>Water and a hat</li>
<li>Temple clothes
<ul>
<li>a top that covers your shoulders</li>
<li>sandals that slip off easily</li>
</ul>
</li>
<li>A charged phone for maps</li>
</ul>
<h2>Plan for the day</h2>
<ol>
<li>Watch the sunrise from a viewing mound.</li>
<li>Visit Ananda Temple in the morning.</li>
<li>Rest through the midday heat.</li>
<li>Watch the sunset over the Irrawaddy River.</li>
</ol>
<p>Check opening times on the
<a href="https://en.wikipedia.org/wiki/Bagan" target="_blank" rel="noopener">Bagan
page on Wikipedia</a>.</p>
<img src="bagan-sunrise.jpg" width="800" height="450"
alt="Hot-air balloons drifting over Bagan's temples at sunrise">
</body>
</html>Quick Quiz 1 / 3
Quick Quiz 2 / 3
Quick Quiz 3 / 3
မှတ်ထားရမယ့် အချက်များ
- Markup မရေးခင် heading outline ကို အရင်ချရေးပါ
- အစဉ်ရှိရင် ol၊ မရှိရင် ul၊ nested list က li ရဲ့ အထဲမှာ
- strong က အရေးကြီးမှု၊ em က ဖိပြောမှု၊ ပုံစံသက်သက်ဆိုရင် CSS
- Link စာသားက ဘယ်ကိုသွားမလဲ ပြောပြီး image တိုင်းမှာ alt၊ width၊ height ထည့်ပါ
HTML Living Standard — WHATWG