이 번역은 완료되지 않았습니다. 이 문서를 번역해 주세요.
<input type="button" />,
<input type="submit" />,
<input type="reset" />,
<input type="image" />)은 모든 유저 에이전트와 보조 기술에서 지원하며 기본으로 키보드와 포커스 기능을 지원하기 때문에, 가능하면
button역할보다 HTML 버튼을 사용하는게 좋습니다.
버튼은 상호작용 컨트롤이며 따라서 포커스가 가능합니다.
button 역할을 추가한 요소가 포커스 불가능한 요소(
tabindex 속성으로 포커스 가능하게 해야 합니다.
Buttons can be operated by both mouse users as well as keyboard users. For native HTML
<button> elements, the button's
onclick event will fire both for mouse clicks and pressing of spacebar ,while the button has focus. But if another tag is used to create a custom button, the
onclick event will only fire when clicked by the mouse cursor, even if
role="button" is used. Because of this, the developer will have to surely add a separate key event handler to the element so that the button can be triggered,even when the space key is pressed.
role="button"alone is not sufficient. It will also be necessary to add a key event handler that listens for the Space key in order to be consistent with native buttons.
An advantage of using role="button" is that it allows the creation of toggle buttons. A toggle button can have two states: pressed and not pressed. Whether a button is a toggle button or not can be indicated with the
aria-pressed attribute in addition to the
aria-pressedis not used the button is not a toggle buttton.
aria-pressed="false"is used the button is a toggle button that is currently not pressed.
is used the button is a toggle button that is currently pressed.
aria-pressed="mixed"is used, the button is considered to be partially pressed.
버튼 이름 붙이기
Buttons should always have an accessible name. For most buttons, this name will be the same as the text inside the button. In some cases, for example for icon buttons, the accessible name can be provided through an aria-label or aria-labelledby attribute.
유저 에이전트와 보조 기술에서의 효과
button role is used, user agents should expose the element as a button control in the operating system's accessibility API. Screen readers should announce the element as a button and describe its accessible name. Speech recognition software should allow the button to be activated by saying "click" followed by the button's accessible name.
ARIA 기본 버튼
In the snippet below, a span element has been given the
button role. Because a
<span> element is used, the
tabindex attribute is required to make the button focusable and part of the tab order. Note that this snippet implies that CSS styles are provided to make the
<span> element look like a button and that
handleBtnKeyUp are event handlers that perform the button's action when clicked and when the Space key is pressed.
<span role="button" tabindex="0" onclick="handleBtnClick()" onKeyUp="handleBtnKeyUp()">Save</span>
ARIA 토글 버튼
In this snippet a native HTML button is converted to a toggle button using the aria-pressed attribute. Note that the tabindex attribute needs not to be used here because the
<button> element is already focusable by default. When the button is activated, the
aria-pressed value keeps on switching between