Movatterモバイル変換


[0]ホーム

URL:


  1. Web
  2. Accessibility
  3. ARIA
  4. ARIA reference
  5. Attributes
  6. aria-required

ARIA: aria-required attribute

Thearia-required attribute indicates that user input is required on the element before a form may be submitted.

Description

When a semantic HTML<input>,<select>, or<textarea> must have a value, it should have therequired attribute applied to it. The HTMLrequired attribute disables submitting the form unless the required form controls have valid values, while ensuring those navigating with the aid of assistive technologies understand which semantic form controls need valid content.

When form controls are created using non-semantic elements, such as a<div> with arole ofcheckbox, thearia-required attribute should be included, with a value oftrue, to indicate to assistive technologies that user input is required on the element for the form to be submittable. Thearia-required attribute can be used with HTML form elements; it is not limited to elements that have an ARIA role assigned.

Similar to the HTMLrequired attribute set on semantic HTML form controls, thearia-required attribute explicitly conveys to assistive technologies that the element is required before a form may be submitted. Therequired attribute on a semantic HTML form control will prevent the form control from being submitted if no value is present — providing native error messaging in some browsers if a required value is invalid when the user attempts to submit the form. Thearia-required attribute, like all ARIA states and properties, has no impact on element functionality. Functionality and behavior must be added in with JavaScript.

Note:ARIA only modifies the accessibility tree, modifying how assistive technology presents content to users. ARIA does not change anything about an element's function or behavior. When not using semantic HTML elements for their intended purpose and default functionality, you must use JavaScript to manage behavior, focus, and ARIA states.

The CSS:required and:optional pseudoclasses match<input>,<select>, and<textarea> elements based on whether they are required or optional, respectively. When using non-semantic elements as form controls, you don't get this CSS pseudoclass selector benefit. You can, however, use attribute selectors if the attribute is present:[aria-required="true"] or[aria-required="false"].

If a form contains both required and optional form elements, the required elements should be indicated visually using a treatment that does not rely solely on color to convey meaning. Typically, descriptive text and/or an icon are used.

Note:Which elements are required should be apparent to all users. Ensure the visual presentation indicates the form control is required in a consistent, visible manner, remembering that color is not enough to convey information.

Examples

The attribute should be added to the form-control role. If the user needs to fill in an email addresstextbox, includearia-required="true" on the textbox.

html
<div>Email Address *</div><div  role="textbox"  contenteditable  aria-labelledby="tblabel"  aria-required="true" ></div>

Note:If the field's label already contains the word "required", it is recommended to leave out thearia-required attribute. This avoids that screen readers read out the term "required" twice.

In this example, JavaScript must be used to prevent the containing form from being submitted if the textbox has no content.

This could be written semantically, without the need for #"email1">Email Address (required)</label><input type="email" required />

Values

true

The element requires a value or must be checked for the form to be submittable.

false

The element is not required.

Associated interfaces

Element.ariaRequired

TheariaRequired property, part of theElement interface, reflects the value of thearia-required attribute.

ElementInternals.ariaRequired

TheariaRequired property, part of theElementInternals interface, reflects the value of thearia-required attribute.

Associated roles

Used in roles:

Inherits into roles:

Specifications

Specification
Accessible Rich Internet Applications (WAI-ARIA)
# aria-required

See also

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2026 Movatter.jp