# Invalid attribute for element

Source: https://xmlvalid.com/errors/invalid-attribute-for-element

> An attribute the pattern does not allow, or a required one missing.

Example message: `Invalid attribute lang for element book`

## Why it happens

- *Invalid attribute*: the attribute is not in the schema for this element.
- *failed to validate attributes*: a required attribute is missing, or one has a value of the wrong type.

## How to fix it

- Remove or rename an attribute the schema doesn't know; add a required one; check the value of each against its datatype.

## Example that fails

```xml
<book isbn="1" lang="en">
  <title>T</title>
  <year>2020</year>
</book>
```

## Fixed

```xml
<book isbn="1">
  <title>T</title>
  <year>2020</year>
</book>
```
