# BaseAttributes

> Provides reusable normalization and rendering for HTML attribute arrays.

[API reference](/docs/api/index.md) › [HTML Helper](/docs/extensions/html-helper/reference/index.md) › [Base](/docs/extensions/html-helper/reference/base/index.md) › BaseAttributes

| abstract class | `UIAwesome\Html\Helper\Base\BaseAttributes` |
| --- | --- |
| Source | [`src/Base/BaseAttributes.php`](https://github.com/ui-awesome/html-helper/blob/main/src/Base/BaseAttributes.php#L25) |

1 subclass:

- [`UIAwesome\Html\Helper\Attributes`](/docs/extensions/html-helper/reference/attributes/index.md)

Provides reusable normalization and rendering for HTML attribute arrays.

## Methods

| Method | Description | Defined by |
| --- | --- | --- |
| [`normalizeAttributes()`](#method-normalizeAttributes) static | Normalizes an array of HTML attributes into a flat associative array with processed values. | `BaseAttributes` |
| [`render()`](#method-render) static | Renders an array of HTML attributes into a string. | `BaseAttributes` |

## Method details

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

```php
public static function normalizeAttributes(mixed[] $attributes, bool $encode = true): array<string, bool|string>
```

Normalizes an array of HTML attributes into a flat associative array with processed values.

Returns a normalized array instead of an HTML string.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$attributes` | `mixed[]` | Associative array of attribute names and values. |
| `$encode` | `bool` | Whether to HTML-encode `string` values. |

**Returns**

`array<string, bool|string>`: Flat associative array with normalized values. Boolean attributes may return `true`.

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

```php
public static function render(mixed[] $attributes): string
```

Renders an array of HTML attributes into a string.

Validates names, normalizes values, and returns attributes in a stable order.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$attributes` | `mixed[]` | Associative array of attribute names and values. |

**Returns**

`string`: Rendered HTML attributes string.