# HasHreflang

> Provides an immutable API for the hreflang attribute.

[API reference](/docs/api/index.md) › [HTML Attribute](/docs/extensions/html-attribute/reference/index.md) › HasHreflang

| trait | `UIAwesome\Html\Attribute\HasHreflang` |
| --- | --- |
| Source | [`src/HasHreflang.php`](https://github.com/ui-awesome/html-attribute/blob/main/src/HasHreflang.php#L18) |

Used by 2 types:

- [`UIAwesome\Html\Metadata\Link`](/docs/extensions/html/reference/metadata/link/index.md)
- [`UIAwesome\Html\Palpable\A`](/docs/extensions/html/reference/palpable/a/index.md)

Provides an immutable API for the `hreflang` attribute.

See also: <https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/link#hreflang>.

## Methods

| Method | Description | Defined by |
| --- | --- | --- |
| [`hreflang()`](#method-hreflang) | Sets the `hreflang` attribute. | `HasHreflang` |

## Method details

### hreflang() <span id="method-hreflang"></span>

```php
public function hreflang(string|Stringable|UnitEnum|null $value): static
```

Sets the `hreflang` attribute.

Declares the language of the linked resource.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$value` | `string\|`[`Stringable`](https://www.php.net/manual/en/class.stringable.php)`\|`[`UnitEnum`](https://www.php.net/manual/en/class.unitenum.php)`\|null` | BCP 47 language tag, or `null` to remove the attribute. |

**Returns**

`static`: New instance with the updated `hreflang` attribute.