{"canonical_url":"https://engineer.company/glossary/button/","content_markdown":"# Button\n\n## What it is\n\nA button is the part of an interface that acts when it is activated: it sends a\nmessage, saves a draft, opens a dialog, mutes a call. On the web it is usually\nthe HTML `\u003cbutton\u003e` element, and in accessibility terms it is anything that\ncarries the `button` role. “Push button” is an older name for the same thing.\n\nWAI-ARIA 1.2 defines the role as “an input that allows for user-triggered\nactions when clicked or pressed” and adds that buttons are mostly used for\ndiscrete actions. A plain command button keeps no state. A toggle button,\nmarked with `aria-pressed`, stays on or off until it is pressed again, and a\nmenu button, marked with `aria-haspopup`, opens a list of further choices.\n\nThe line that matters most runs between a button and a link. A link takes the\nreader somewhere; a button changes something where the reader already is. The\nARIA Authoring Practices Guide calls the two functions distinctly different\nand, when a link is drawn as a button or the reverse, prefers changing the\nvisual design to match the function over borrowing the other element's role.\n\nThe HTML Living Standard describes the `\u003cbutton\u003e` element as a button labelled\nby its contents. Its `type` attribute has three keywords. `submit` sends the\nform the button belongs to, `reset` returns the form's fields to their starting\nvalues, and `button` does nothing by itself, leaving the action to script. When\n`type` is missing or misspelt, the button is in the Auto state, and a button in\nthat state inside a form, with no command attached, is a submit button. No\ninteractive content may sit inside it: no link, no field and no second button.\n\nThe standard also lets a button act on another element without script:\n`commandfor` names the target by its ID, and `command` says what to do with it,\nsuch as showing a popover or opening a dialog as a modal. How much of that a\ngiven browser ships is a question for that browser's own release notes.\n\n## Why it matters\n\nA button is where reading turns into doing: buying, sending, saving and\ndeleting all pass through one. A button that some people cannot find, reach or\nunderstand shuts them out of the part of the product that pays for it.\n\n**The real element arrives with its behaviour attached.** A `\u003cbutton\u003e` takes\nkeyboard focus, runs its action on Space and on Enter, tells assistive\ntechnology that it is a button and what it is called, and stops responding when\nit carries `disabled`. The Understanding document for WCAG 2.2 success criterion\n4.1.2, Name, Role, Value, notes that standard HTML controls already meet the\ncriterion when they are used according to the specification. A `\u003cdiv\u003e` with a\nclick handler has none of this, and every piece left out shuts somebody out.\n\n**The name is the promise.** A screen reader announces a button by its\naccessible name and its role, so the name has to say what the button does, not\nwhat it looks like. The APG adds a rule for toggles that is easy to break: the\nlabel stays the same while the state changes. A button named “Mute” is\nannounced as “Mute toggle button pressed” when it is on. If a design prefers a\nlabel that switches between “Mute” and “Unmute”, `aria-pressed` is not needed,\nbecause the label itself reports the state.\n\n**Size is a requirement, not a taste.** WCAG 2.2 success criterion 2.5.8, Target\nSize (Minimum), at level AA, asks that a pointer target be “at least 24 by 24\nCSS pixels”. The exceptions cover small targets with enough space around them, a\nfull-size control elsewhere on the page that does the same job, links inside a\nsentence, controls whose size the browser sets, and sizes that are essential. A\ntremor, a moving bus and a thumb on a phone all make small targets harder.\n\n**Focus has to land somewhere sensible.** After a press, the APG expects focus\nto move inside a dialog that the button opened and, when that dialog closes,\ntypically to return to the button that opened it. When the press leaves the\nreader in the same context, as an Apply button does, focus typically stays on\nthe button. A keyboard user whose focus jumps to the top of the page after every\nsave starts the page over each time.\n\n## What it looks like in practice\n\nThe clearest case starts with one announcement. In a SwiftUI application built\nfrom system symbols, the screen reader read the send button aloud as “arrow up\ncircle, button”, because an unlabelled symbol is announced by its internal name.\nThe work of\n[naming all seventeen icon-only controls for screen readers](/portfolio/named-all-17-icons-for-screen-readers/)\ngave each one a label naming its action rather than its shape, and where a\ncontrol's meaning depends on its state, the label follows the state. The more\nlasting part is the check: a linter that finds the construction creating an\nicon-only control and requires an accessibility label within eight lines of it.\nEight lines was chosen by measurement and is deliberately crude: the rule proves\nthat a label exists nearby, not that it is right, and someone still has to\nlisten.\n\nA second lesson is about what a button cannot do. In\n[the payments and entitlements layer](/portfolio/built-stripe-and-in-app-purchase-entitlements/)\nbuilt on Stripe and on Apple and Google in-app purchase, a separate access\nschema of 11 tables decides whether an account may use the company directory,\nsearch and data export. The server asks that question again for each request it\nserves, because a hidden button is a courtesy and not a control.\n\nButtons matter to readers that are not people, too. The site's page on being\n[ready for AI agents](/ai-ready/) notes that many agents that work a browser\nread a page through its accessibility tree, as a screen reader does. Real\nbuttons and labelled forms are part of what lets an agent find a form and fill\nit in.\n\nThis site's own templates contain no `\u003cbutton\u003e` element at all. The filled\n“Get in touch” call is an `\u003ca\u003e` styled as a button, because it leads to the\ncontact page, and its stylesheet rule sets a `min-height` of 24 pixels with a\ncomment citing success criterion 2.5.8. The main menu is a `\u003cdetails\u003e` element\nwhose `\u003csummary\u003e` opens and closes it, and the template's comment says that the\nbrowser owns the open state and the button semantics, with no script.\n\n## Where it goes wrong\n\n- **A clickable box stands in for the element.** A `\u003cdiv\u003e` or `\u003cspan\u003e` with a\n  click handler answers a mouse and little else: it takes no focus, ignores\n  Space and Enter, and is announced as plain text. Adding `role=\"button\"`\n  corrects the announcement only; focus and keys still have to be written by\n  hand.\n- **A link does a button's job, or the reverse.** A link that deletes a record\n  can be opened in a new tab or bookmarked, which repeats the deletion or loses\n  track of it. A button that only navigates cannot be opened in a new tab and\n  has no address to copy.\n- **A bare button inside a form submits it.** Because a missing `type` puts a\n  button in the Auto state, an “Add another row” or “Show password” button\n  placed inside a form sends the form the moment it is pressed. Writing\n  `type=\"button\"` on every button that is not meant to submit removes the\n  surprise.\n- **The icon is the whole label.** A bin, a pencil or an arrow means something\n  to the person who drew it. With no accessible name, the screen reader reads a\n  file name, a symbol name or just “button”. A visible word is best; where there\n  is no room for one, an accessible name that states the action fills the gap.\n- **A hidden or disabled button is treated as security.** Taking the button off\n  the page stops honest users only; the request behind it can still be sent, and\n  the server has to decide on its own whether this account may do this.\n\n## Further reading\n\n- [WAI-ARIA 1.2: button role](https://www.w3.org/TR/wai-aria-1.2/#button)\n  — the role's definition, its toggle and menu variants, and the states and\n  properties it supports.\n- [HTML Living Standard: the button element](https://html.spec.whatwg.org/multipage/form-elements.html#the-button-element)\n  — the content model, the submit, reset and button types, the Auto state, and\n  the `command` and `commandfor` attributes.\n- [ARIA Authoring Practices Guide: Button Pattern](https://www.w3.org/WAI/ARIA/apg/patterns/button/)\n  — buttons versus links, keyboard behaviour, where focus goes after a press and\n  the rule for toggle labels.\n- [Understanding SC 2.5.8: Target Size (Minimum)](https://www.w3.org/WAI/WCAG22/Understanding/target-size-minimum.html)\n  — the 24 by 24 pixel minimum, the spacing test and the other exceptions.\n- [Understanding SC 4.1.2: Name, Role, Value](https://www.w3.org/WAI/WCAG22/Understanding/name-role-value.html)\n  — why every control needs a name and a role that software can read, and when\n  standard HTML controls already meet the criterion.\n\n\u003chttps://engineer.company/glossary/button/\u003e\n","date_modified":"2026-10-20T21:59:50Z","description":"Buttons versus links, what the HTML element gives for free, how to name and size one, and the mistakes that hide a button from some of its users.","formats":{"gemtext":"https://engineer.company/glossary/button/index.gmi","gopher":"https://engineer.company/glossary/button/gophermap","html":"https://engineer.company/glossary/button/","json":"https://engineer.company/glossary/button/index.json","markdown":"https://engineer.company/glossary/button/index.md","pdf":"https://engineer.company/glossary/button/index.pdf"},"kind":"page","language":"en","title":"What is a button?","url":"https://engineer.company/glossary/button/","version":1}