[{"data":1,"prerenderedAt":312,"buildId":313},["ShallowReactive",2],{"page-\u002Flearn\u002Fsemantic-html":3},{"id":4,"title":5,"body":6,"description":295,"extension":296,"how_to_steps":297,"hub":284,"meta":298,"navigation":299,"path":300,"primary_keyword":301,"published_at":302,"schema_types":303,"seo":306,"status":307,"stem":308,"updated_at":309,"wave":310,"__hash__":311},"pages\u002Flearn\u002Fsemantic-html.md","Semantic HTML: Meaning Over Markup (With Examples)",{"type":7,"value":8,"toc":287},"minimark",[9,13,18,39,60,78,82,96,128,143,163,167,170,180,187,193,200,207,211,236,239,247,251,260,269],[10,11,12],"p",{},"Semantic HTML means choosing elements for what their content is or what a control does.\nUse a heading for a heading, a link to go somewhere, and a button to do something.\nA line of text can look like a heading because a designer made it large.\nA real heading keeps its level and meaning even when the stylesheet is gone.",[14,15,17],"h2",{"id":16},"what-semantic-means-in-html","What semantic means in HTML",[10,19,20,21,25,26,28,29,31,32,34,35,38],{},"Suppose the library posts its Saturday opening hours.\nYou can put the label \"Saturday hours\" in a ",[22,23,24],"code",{},"div"," and make the letters large and bold.\nOn screen, that might look the same as an ",[22,27,14],{},".\nThe difference shows up in a screen reader's heading list.\nThe ",[22,30,14],{}," is a place to jump to.\nThe styled ",[22,33,24],{}," is just a container.\nA class name can say what the code is for.\nBut a class called ",[22,36,37],{},"section-title"," does not give an element a heading role.",[10,40,41,42,45,46,48,49,52,53,55,56,59],{},"Start by reading the page as if it were an outline.\nFor a page about visiting the library, \"Plan your visit\" could be the ",[22,43,44],{},"h1",".\n\"Saturday hours\" and \"Getting here\" can be two ",[22,47,14],{}," headings.\nIf \"Getting here\" has directions by bus and by bike, those can be ",[22,50,51],{},"h3"," headings under it.\nPick the level from how the topics relate.\nThen use CSS to make each heading the size you want.\nChanging an ",[22,54,14],{}," to an ",[22,57,58],{},"h4"," to get smaller letters makes the structure harder to follow.",[10,61,62,63,66,67,70,71,74,75,77],{},"Some elements also bring behavior.\nAn ",[22,64,65],{},"a"," with an ",[22,68,69],{},"href"," can take someone to the library's directions page.\nThe browser then lets people copy the address or open it in a new tab.\nA ",[22,72,73],{},"button"," can open a menu on the current page.\nIt works with a keyboard.\nYou do not have to teach a ",[22,76,24],{}," to respond to keys.\nFor the menu to open, you still need to connect the button to that behavior.",[14,79,81],{"id":80},"the-elements-that-earn-their-keep","The elements that earn their keep",[10,83,84,85,88,89,91,92,95],{},"Use ",[22,86,87],{},"main"," for the content that makes this page different from the other pages on the site.\nOn the library's visit page that means the hours and directions.\nIt does not mean the site menu that appears on every page.\nUse one visible ",[22,90,87],{}," and put major groups of navigation links in ",[22,93,94],{},"nav",".\nA single link to the bus timetable in a paragraph can stay where it is.",[10,97,98,99,102,103,106,107,110,111,113,114,116,117,119,120,123,124,127],{},"A page-level ",[22,100,101],{},"header"," can hold the site name and the menu.\nA page-level ",[22,104,105],{},"footer"," can hold contact or copyright information.\nAn ",[22,108,109],{},"article"," can also have its own ",[22,112,101],{}," for a headline and byline.\nIt can have its own ",[22,115,105],{}," for a credit.\nUse ",[22,118,109],{}," for a piece that could stand on its own, like a news item about an upcoming library closure.\nUse ",[22,121,122],{},"section"," for a distinct part of a larger whole.\nIt usually has a heading, such as the directions on the visit page.\nUse ",[22,125,126],{},"aside"," for related material outside the main thread, such as a note about another nearby branch.",[10,129,130,131,134,135,138,139,142],{},"The same decisions apply inside those regions.\nUse ",[22,132,133],{},"ul"," for several options where the order does not matter.\nUse ",[22,136,137],{},"ol"," for instructions people must follow in order.\nA table makes sense when someone needs to compare which branches are open on which days.\nUse labeled header cells that tie each time to its branch and day.\nUse paragraphs for prose.\nUse a ",[22,140,141],{},"label"," for a form field.\nThen people can tell what to enter even after a placeholder disappears.",[10,144,145,146,148,149,152,153,155,156,159,160,162],{},"Keep a ",[22,147,24],{}," when all you need is a wrapper for layout.\nIf it groups the hours and directions so CSS can put them in two columns, it has a useful job.\nIt is not a section of its own.\nA ",[22,150,151],{},"span"," can style a few words inside a sentence.\nIt does not give those words a new role.\nWhen you see a container named ",[22,154,94],{},", ",[22,157,158],{},"heading",", or ",[22,161,73],{},", ask whether the matching HTML element could do the job itself.",[14,164,166],{"id":165},"before-and-after-div-soup-vs-meaning","Before and after: div soup vs meaning",[10,168,169],{},"Here is a fragment of the visit page built from generic containers.\nIt relies on its classes for appearance.\nThe two labels look like links, but they do not work as navigation.",[171,172,178],"pre",{"className":173,"code":175,"language":176,"meta":177},[174],"language-html","\u003Cdiv class=\"site-header\">\n  \u003Cdiv class=\"site-name\">Cedar Library\u003C\u002Fdiv>\n  \u003Cdiv class=\"menu\">\n    \u003Cdiv class=\"menu-link\">Hours\u003C\u002Fdiv>\n    \u003Cdiv class=\"menu-link\">Directions\u003C\u002Fdiv>\n  \u003C\u002Fdiv>\n\u003C\u002Fdiv>\n\u003Cdiv class=\"content\">\n  \u003Cdiv class=\"page-title\">Plan your visit\u003C\u002Fdiv>\n  \u003Cdiv class=\"section-title\" id=\"hours\">Saturday hours\u003C\u002Fdiv>\n  \u003Cdiv>Open from ten to four.\u003C\u002Fdiv>\n  \u003Cdiv class=\"section-title\" id=\"directions\">Getting here\u003C\u002Fdiv>\n  \u003Cdiv>Use the Oak Street entrance.\u003C\u002Fdiv>\n\u003C\u002Fdiv>\n","html","",[22,179,175],{"__ignoreMap":177},[10,181,182,183,186],{},"Keep the same information and mark up each part for its job.\nThese are body fragments.\nPut each version inside the ",[22,184,185],{},"body"," of its own HTML file to try it in a browser.",[171,188,191],{"className":189,"code":190,"language":176,"meta":177},[174],"\u003Cheader class=\"site-header\">\n  \u003Cp class=\"site-name\">Cedar Library\u003C\u002Fp>\n  \u003Cnav class=\"menu\" aria-label=\"On this page\">\n    \u003Ca class=\"menu-link\" href=\"#hours\">Hours\u003C\u002Fa>\n    \u003Ca class=\"menu-link\" href=\"#directions\">Directions\u003C\u002Fa>\n  \u003C\u002Fnav>\n\u003C\u002Fheader>\n\u003Cmain class=\"content\">\n  \u003Ch1 class=\"page-title\">Plan your visit\u003C\u002Fh1>\n  \u003Ch2 class=\"section-title\" id=\"hours\">Saturday hours\u003C\u002Fh2>\n  \u003Cp>Open from ten to four.\u003C\u002Fp>\n  \u003Ch2 class=\"section-title\" id=\"directions\">Getting here\u003C\u002Fh2>\n  \u003Cp>Use the Oak Street entrance.\u003C\u002Fp>\n\u003C\u002Fmain>\n",[22,192,190],{"__ignoreMap":177},[10,194,195,196,199],{},"The class names can stay.\nRules that target those classes can still apply.\nCheck your stylesheet for selectors like ",[22,197,198],{},"div.menu-link",".\nThey need to match the new element before you can compare the two designs.\nBrowsers give headings and paragraphs their own default margins.\nExpect a difference in spacing until you set the margins you want.",[10,201,202,203,206],{},"On the revised page, press Tab to reach \"Hours,\" then Enter to follow it.\nThe address should end in ",[22,204,205],{},"#hours",".\nThis works even when the page is too short for the browser to scroll to the heading.\nA heading is a valid link target without being a separate control in the Tab order.\nIn the first version, none of the containers will be a Tab stop on their own.\nThat test shows what changed even if you style both versions to look alike.",[14,208,210],{"id":209},"landmarks-and-screen-readers","Landmarks and screen readers",[10,212,213,214,216,217,219,220,222,223,225,226,228,229,231,232,235],{},"Landmarks are named page regions.\nAssistive technology can offer them as navigation shortcuts.\nThe W3C's ARIA in HTML and HTML Accessibility API Mappings describe how native elements supply these roles.\n",[22,215,87],{}," maps to the main landmark.\n",[22,218,94],{}," maps to navigation.\nA page-level ",[22,221,101],{}," and ",[22,224,105],{}," can provide the banner and content information landmarks.\nThe ones inside an ",[22,227,109],{}," do not provide those page landmarks.\nA ",[22,230,122],{}," can become a region landmark when it has an accessible name, such as one supplied by ",[22,233,234],{},"aria-labelledby"," pointing to its heading.\nA heading inside a section does not give the section that name by itself.",[10,237,238],{},"Label navigation landmarks when visitors need to tell different menus apart.\nFor instance, the library may add a site-wide menu above the on-page links.\nGive it a distinct name such as \"Library site.\"\nPeople using a landmark list can then choose between the site navigation and \"On this page.\"\nSave named regions for places readers will want to jump to.\nLabel every block and the landmark list gets harder to scan.",[10,240,241,242,246],{},"In the browser's accessibility inspector, look for the navigation and main landmarks.\nCheck the heading levels too.\nWith a screen reader, try to find Saturday hours using headings, then try the same task using landmarks and links.\nThe headings may be right and the page can still fall short.\nIf you cannot reach the links by keyboard, you have a problem to fix.\nThe ",[65,243,245],{"href":244},"\u002Flearn\u002Fhtml-accessibility","HTML accessibility"," guide covers keyboard focus and testing controls in more depth.",[14,248,250],{"id":249},"how-meaning-helps-search","How meaning helps search",[10,252,253,254,256,257,259],{},"Use a descriptive page title and a main heading.\nThey should tell readers what they will find.\nUse real links for pages they can visit next.\nGoogle's Search Central documentation on crawlable links recommends an ",[22,255,65],{}," element with an ",[22,258,69],{}," and descriptive link text.\nIn the library example, a separate directions page could be linked as \"Bus and bike directions.\"\nThe destination is then clear without reading the rest of the paragraph.",[10,261,262,263,265,266,268],{},"A search engine can follow a link and read a page's text.\nThat is separate from how it ranks the page.\nChanging every ",[22,264,24],{}," to a ",[22,267,122],{}," cannot make a page about another subject answer a search for library hours.\nWrite the hours as text on the page and use a heading that helps someone find them once they arrive.",[10,270,271,272,276,277,281,282,286],{},"For historical context, the ARIA test inventory ",[65,273,275],{"href":274},"\u002Fwiki\u002Findex.php\u002FARIATestTests","from the 2007-2009 archive"," records how people planned to test the structure and behavior exposed by common widgets.\nIn ",[65,278,280],{"href":279},"\u002Fpipermail\u002Flist_html4all.org\u002F2007-November\u002F000597.html","the original mailing list discussion",", contributors debated how nested sections should affect numbered headings in HTML5.\nRead that exchange as a record of a design debate.\nThen test explicit heading levels in the browser and assistive technology you support today.\nTo practice on another page, pick a sample from the ",[65,283,285],{"href":284},"\u002Flearn","Learn HTML hub",".\nFind its main content by reading the headings before looking at any CSS.",{"title":177,"searchDepth":288,"depth":288,"links":289},2,[290,291,292,293,294],{"id":16,"depth":288,"text":17},{"id":80,"depth":288,"text":81},{"id":165,"depth":288,"text":166},{"id":209,"depth":288,"text":210},{"id":249,"depth":288,"text":250},"Why semantic HTML beats div soup: the elements that matter, when to use them, and how meaning improves accessibility and SEO.","md",null,{},true,"\u002Flearn\u002Fsemantic-html","semantic html","2026-12-01T05:35:41Z",[304,305],"Article","BreadcrumbList",{"title":5,"description":295},"draft","learn\u002Fsemantic-html","2026-12-01T06:15:12Z","1","VoOXSm01N0DVdGs8N1xZSEx2Is0KehhyEvxTXtBXsj8",1796185435705,"a1d53563-3a78-4678-8315-e5bd6a5bd80c"]