HTML elements carry semantics: the standard defines what each one represents. <ol> is an ordered list, <nav> is a block of navigation links, <button> is a control that does something. Any program that reads the page, not only the screen renderer, can use that meaning. The standard's own examples are speech browsers that read headings in a different voice and let users jump between them, and search engines that use headings to index sections.
In practice semantics buy three things:
- The accessibility tree. Browsers map elements to roles (the table is in ARIA in HTML):
nav→navigation,main→main,button→button,ul→list. Screen readers announce the role and let users navigate by landmark, heading or list.divandspanmap togeneric, which is announced as nothing. - Built-in behaviour. A
<button>is focusable, activates on click and on the keyboard, can bedisabled, and submits its form. A<div class="btn">has none of that until you write it, and the hand-made version usually misses something. - Other consumers. Reader modes, search engines and browser features like "jump to heading" read the same structure.
A div is right when there is no meaning to express. The HTML standard calls it "an element of last resort": a wrapper for flexbox or grid, a hook for a class, a group sharing a lang attribute, or a dt/dd group inside <dl>. span is the inline equivalent. Picking section or article for every layout box doesn't add meaning either; it adds noise.
role="button" on a div changes only what assistive technology is told. It doesn't add focus, keyboard handling or form behaviour, so the native element is the better tool.