[{"data":1,"prerenderedAt":214,"buildId":215},["ShallowReactive",2],{"page-\u002Flearn\u002Fhtml-accessibility":3},{"id":4,"title":5,"body":6,"description":196,"extension":197,"how_to_steps":198,"hub":182,"meta":199,"navigation":200,"path":201,"primary_keyword":202,"published_at":203,"schema_types":204,"seo":208,"status":209,"stem":210,"updated_at":211,"wave":212,"__hash__":213},"pages\u002Flearn\u002Fhtml-accessibility.md","HTML Accessibility: Build Pages Everyone Can Use",{"type":7,"value":8,"toc":185},"minimark",[9,13,18,21,24,39,50,54,57,72,82,93,99,106,110,113,116,119,134,138,141,144,147,151,154,158,167],[10,11,12],"p",{},"HTML accessibility means marking up a web page so people can read it, find their way around, and use its controls in more than one way.\nStart with real headings, links, buttons, and form labels.\nThese give the browser information it can pass to tools such as a screen reader.\nThey also give many controls working keyboard support without extra code.",[14,15,17],"h2",{"id":16},"why-html-is-the-accessibility-layer","Why HTML is the accessibility layer",[10,19,20],{},"Imagine a page for a repair cafe.\nA visitor needs to find the hours, check what the cafe can fix, and sign up for a slot.\nOne person might scroll and look for large text.\nSomeone who uses a screen reader might ask for a list of headings and jump straight to \"Hours.\"\nIf the page uses a bold paragraph for \"Hours,\" it may look like a heading, but that paragraph will not be in the screen reader's heading list.",[10,22,23],{},"Browsers interpret the elements that make up the page.\nThey pass relevant information, such as a control's name and whether it is checked, to the tools that people use to access the page.\nThis does not mean everyone hears the same words or uses the same commands.\nIt does mean the same HTML can give several people the information they need to find a booking form, even if their tools work in different ways.",[10,25,26,27,31,32,34,35,38],{},"Start the repair cafe page with one clear ",[28,29,30],"code",{},"h1"," for the page title.\nUse ",[28,33,14],{}," for \"Hours,\" \"What we fix,\" and \"Book a slot.\"\nUse ",[28,36,37],{},"h3"," under \"What we fix\" if you need separate parts for bikes and small appliances.\nPick the heading level from the way the topics fit together, not from the size of the letters.\nUse CSS when the letters need to be bigger or smaller.",[10,40,41,42,45,46,49],{},"Put the page's main content inside ",[28,43,44],{},"main"," and the main navigation inside ",[28,47,48],{},"nav",".\nKeep the source order the same as the intended reading order.\nFor example, put the place and time before the booking form in the HTML, even if a wider layout puts the two side by side.\nWhen the page is read aloud or shown in a single column, people should get the details before they are asked to act.",[14,51,53],{"id":52},"semantics-first-aria-second","Semantics first, ARIA second",[10,55,56],{},"Semantic HTML means choosing elements for what they do.\nA link takes someone to a new place, such as the booking page.\nA button performs an action, such as showing more dates on the current page.\nBoth can be styled to fit your design, so their appearance need not decide which element you use.",[10,58,59,60,63,64,67,68,71],{},"A ",[28,61,62],{},"div"," styled to look like a button does not get a button's keyboard behavior or role for free.\nAdding ",[28,65,66],{},"role=\"button\""," tells a screen reader what it should be, but does not make Space or Enter activate it.\nUse a real button and give it a name that tells people what pressing it will do.\nFor a button inside a form, ",[28,69,70],{},"type=\"button\""," makes it clear that it should not submit the form.",[73,74,80],"pre",{"className":75,"code":77,"language":78,"meta":79},[76],"language-html","\u003Ca href=\"hours.html\">Repair cafe hours\u003C\u002Fa>\n\u003Cbutton type=\"submit\">Book a repair slot\u003C\u002Fbutton>\n","html","",[28,81,77],{"__ignoreMap":79},[10,83,84,85,88,89,92],{},"Give inputs visible labels and make each label's ",[28,86,87],{},"for"," match the input's ",[28,90,91],{},"id",".\nPeople can then click or tap the label, and a screen reader can tell them what to enter when they reach the field.\nA hint inside the input does not replace a label.\nThe hint can disappear as soon as they type, right when they may need to check what the field asked for.",[73,94,97],{"className":95,"code":96,"language":78,"meta":79},[76],"\u003Clabel for=\"item\">What needs fixing?\u003C\u002Flabel>\n\u003Cinput id=\"item\" name=\"item\" required>\n",[28,98,96],{"__ignoreMap":79},[10,100,101,102,105],{},"ARIA stands for Accessible Rich Internet Applications.\nIts attributes fill gaps when the HTML does not carry enough information.\nFor example, an icon-only button that closes a panel can use ",[28,103,104],{},"aria-label=\"Close panel\""," to give it a name.\nIf the button already has visible text, use that text as its name unless there is a specific reason to add information.\nAvoid labels that contradict what a person sees: someone who uses voice commands may try to speak the visible label to activate the control.",[14,107,109],{"id":108},"keyboard-and-focus-basics","Keyboard and focus basics",[10,111,112],{},"Load the page and put the mouse aside.\nPress Tab and watch which link or control has focus, meaning it will receive your next key press.\nPress Shift+Tab to move back.\nUse Enter for links, and try both Enter and Space on buttons.\nThen finish the whole booking task, including a run with a missing answer so you can see how the page handles an error.",[10,114,115],{},"Every stop needs a visible focus mark.\nKeep the browser's outline unless you provide a clear replacement.\nCheck it against both light and dark parts of the page, not only against the background of the button.\nAt a narrow width, look for sticky headers or banners that might cover the focused link.\nA focus ring is no help if you cannot see the control it surrounds.",[10,117,118],{},"For a page with repeated navigation, put a \"Skip to main content\" link before those controls.\nIt can stay out of the way until it receives focus.\nWhen activated, it should put the reader at the main content so the next Tab continues there, rather than sending them back through the menu.\nTest that second Tab before you call the skip link done.",[10,120,121,122,125,126,129,130,133],{},"If a dialog opens over the page, focus needs to move into it.\nPeople should be able to close it with the keyboard and continue from the button that opened it, if that button is still there.\nA native modal ",[28,123,124],{},"dialog"," opened with ",[28,127,128],{},"showModal()"," handles much of the work, but you still need to choose a sensible first focus target and test how the dialog closes.\nFor a short optional note, a plain ",[28,131,132],{},"details"," disclosure may be a better fit than a dialog.",[14,135,137],{"id":136},"testing-tools-that-tell-the-truth","Testing tools that tell the truth",[10,139,140],{},"Start with a keyboard pass and a narrow browser window.\nZoom in and make sure headings, text, and controls reflow without losing information.\nFor normal text, the Web Content Accessibility Guidelines (WCAG) 2.2 level AA call for a contrast ratio of at least 4.5 to 1 in most cases.\nUse a contrast checker on the actual text and background, and check that errors are marked with words rather than color alone.\nTry the booking link on a phone, too: it should be easy to tap without hitting another control.",[10,142,143],{},"Next run an automated checker such as axe or the accessibility audit in Lighthouse.\nIt can catch some missing names and contrast failures, but a pass cannot tell you whether a link named \"More\" points to the right place or whether an error explains how to fix the form.\nUse the browser's accessibility inspector to check what role, name, and state a control exposes.\nThen try a real screen reader, such as VoiceOver on Apple devices or NVDA on Windows.\nAsk it for the headings and links, then listen to one full task from start to finish.",[10,145,146],{},"Keep notes a teammate can act on.\n\"Tab from the date field; focus goes behind the banner and the Book button cannot be seen\" is easier to fix than \"keyboard broken.\"\nWrite down the browser, the device or screen reader, and the first step that fails.\nAfter a fix, repeat the same steps in both directions and check the next control as well.\nThis is a practical first pass, not proof that a site meets every WCAG 2.2 AA requirement.",[37,148,150],{"id":149},"can-aria-make-a-custom-control-work-by-itself","Can ARIA make a custom control work by itself?",[10,152,153],{},"No.\nARIA can describe a role or state, but it does not supply keyboard actions or move focus for you.\nStart with a native control whenever one fits the job.",[14,155,157],{"id":156},"what-our-2007-2009-archive-predicted","What our 2007-2009 archive predicted",[10,159,160,161,166],{},"The ARIA test template ",[162,163,165],"a",{"href":164},"\u002Fwiki\u002Findex.php\u002FARIATestTemplate","from the 2007-2009 archive"," asked testers to record their setup and what actually happened.\nThat is still a useful habit: separate what you expect from what a reader can do with the browser and tools they have.",[10,168,169,170,174,175,179,180,184],{},"Questions about how people would use web features also came up in ",[162,171,173],{"href":172},"\u002Fpipermail\u002Flist_html4all.org\u002F2007-August\u002F000155.html","the original mailing list discussion",".\nRead it as a record of questions and tests from that time, then test today's page before relying on an old result.\nPractice choosing native elements with the guide to ",[162,176,178],{"href":177},"\u002Flearn\u002Fsemantic-html","semantic HTML",".\nFor another exercise, return to the ",[162,181,183],{"href":182},"\u002Flearn","Learn HTML hub",".",{"title":79,"searchDepth":186,"depth":186,"links":187},2,[188,189,190,191,195],{"id":16,"depth":186,"text":17},{"id":52,"depth":186,"text":53},{"id":108,"depth":186,"text":109},{"id":136,"depth":186,"text":137,"children":192},[193],{"id":149,"depth":194,"text":150},3,{"id":156,"depth":186,"text":157},"A practical guide to accessible HTML: semantic markup, ARIA basics, keyboard support, and testing. Written for the HTML For All mission.","md",null,{},true,"\u002Flearn\u002Fhtml-accessibility","html accessibility","2026-12-01T04:29:57Z",[205,206,207],"Article","BreadcrumbList","FAQPage",{"title":5,"description":196},"draft","learn\u002Fhtml-accessibility","2026-12-01T05:35:41Z","0","-D_jgoAz8zs6GuDSioCPxU3e-a8hDQ-UhQPEVYvhA1Q",1796185435703,"a1d53563-3a78-4678-8315-e5bd6a5bd80c"]