# Element “a” is missing one or more of the following attributes: “aria-checked”, “aria-level”, “href”, “role”.

> Canonical HTML version: https://rocketvalidator.com/html-validation/element-a-is-missing-one-or-more-of-the-following-attributes-aria-checked-aria-level-href-role
> Attribution: Rocket Validator (https://rocketvalidator.com)
> License: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/)

An `<a>` element without an `href` attribute can't use `aria-expanded` unless it also has a `role` that supports that state.

Without `href`, an `<a>` isn't a link. HTML treats it as a placeholder, and its ARIA role is `generic`. The `aria-expanded` attribute only applies to certain roles, such as `button`, `link`, `tab` and `menuitem`, so on a placeholder anchor it describes a state that screen readers have nothing to attach to. The anchor also can't receive keyboard focus, so keyboard users can't reach the control.

This usually comes from a menu or dropdown toggle written as `<a aria-expanded="false">` and wired up with JavaScript. The message also lists `aria-checked` and `aria-level`, but adding either of them doesn't fix the element: the validator then asks for `href` or `role` instead. Add an `href` if the element takes the user somewhere. If it opens and closes part of the page, replace it with a `<button type="button">`, which is focusable, works with the keyboard and supports `aria-expanded` without extra attributes. Keeping the `<a>` with `role="button"` and `tabindex="0"` also passes validation, but then your script has to handle the Enter and Space keys.

## Invalid example

```html
<a class="menu-toggle" aria-expanded="false" aria-controls="account-menu">Account</a>
<ul id="account-menu" hidden>
  <li><a href="/profile">Profile</a></li>
  <li><a href="/logout">Log out</a></li>
</ul>
```

## Valid example

```html
<button type="button" class="menu-toggle" aria-expanded="false" aria-controls="account-menu">Account</button>
<ul id="account-menu" hidden>
  <li><a href="/profile">Profile</a></li>
  <li><a href="/logout">Log out</a></li>
</ul>
```
