# Bad value “text” for attribute “role” on element “span”.

> Canonical HTML version: https://rocketvalidator.com/html-validation/bad-value-text-for-attribute-role-on-element-span
> Attribution: Rocket Validator (https://rocketvalidator.com)
> License: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/)

A `span` element cannot have `role="text"` because `text` is not a valid WAI-ARIA role.

The `role` attribute accepts only values defined in the [WAI-ARIA specification](https://www.w3.org/TR/wai-aria-1.2/#role_definitions). Common valid roles include `button`, `alert`, `status`, `img`, `presentation`, and many others, but `text` is not among them.

The non-standard `role="text"` was sometimes used as a workaround to prevent screen readers like VoiceOver from splitting inline elements into separate announcements. For example, when a `span` wraps mixed text and inline elements, some screen readers read each child element as a separate item. Using `role="text"` forced them to treat the content as a single text run. However, this was never part of the ARIA spec and causes a validation error.

If the goal is to group inline content so screen readers announce it as one continuous phrase, use `role="group"` with an `aria-label` that provides the full text. Alternatively, if the `span` has no semantic purpose, remove the `role` attribute entirely.

## HTML examples

### Invalid usage

```html
<p>
  <span role="text">
    Sale price: <strong>$49.99</strong>
  </span>
</p>
```

### Valid alternatives

Remove the `role` if it serves no accessibility purpose:

```html
<p>
  <span>
    Sale price: <strong>$49.99</strong>
  </span>
</p>
```

Or use `role="group"` with `aria-label` to ensure screen readers announce the content as a single phrase:

```html
<p>
  <span role="group" aria-label="Sale price: $49.99">
    Sale price: <strong>$49.99</strong>
  </span>
</p>
```
