# ContentInterface

> Defines the contract for elements that accept child content.

[API reference](/docs/api/index.md) › [HTML Contracts](/docs/extensions/html-contracts/reference/index.md) › [Element](/docs/extensions/html-contracts/reference/element/index.md) › ContentInterface

| interface | `UIAwesome\Html\Contracts\Element\ContentInterface` |
| --- | --- |
| Source | [`src/Element/ContentInterface.php`](https://github.com/ui-awesome/html-contracts/blob/main/src/Element/ContentInterface.php#L16) |

Implemented by 2 types:

- [`ClearableContentInterface`](/docs/extensions/html-contracts/reference/element/clearablecontentinterface/index.md)
- [`InlineInterface`](/docs/extensions/html-contracts/reference/element/inlineinterface/index.md)

Defines the contract for elements that accept child content.

Content appended through [`content()`](/docs/extensions/html-contracts/reference/element/contentinterface/index.md#method-content) is encoded, whereas content appended through [`html()`](/docs/extensions/html-contracts/reference/element/contentinterface/index.md#method-html) is preserved
verbatim.

## Methods

| Method | Description | Defined by |
| --- | --- | --- |
| [`content()`](#method-content) abstract | Appends encoded content. | `ContentInterface` |
| [`getContent()`](#method-getContent) abstract | Returns the content assigned to the element. | `ContentInterface` |
| [`html()`](#method-html) abstract | Appends trusted raw HTML content without encoding or sanitizing it. | `ContentInterface` |

## Method details

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

```php
abstract public function content(string|Stringable|UnitEnum ...$values): static
```

Appends encoded content.

Backed enums use their value (including `0`); pure enums use their name. Values are normalized before encoding.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `...$values` | `string\|`[`Stringable`](https://www.php.net/manual/en/class.stringable.php)`\|`[`UnitEnum`](https://www.php.net/manual/en/class.unitenum.php) | Content to be encoded and appended. |

**Returns**

`static`: New instance with appended encoded content.

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

```php
abstract public function getContent(): string
```

Returns the content assigned to the element.

**Returns**

`string`: Content value assigned to the element. Never `null`.

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

```php
abstract public function html(string|Stringable|UnitEnum ...$values): static
```

Appends trusted raw HTML content without encoding or sanitizing it.

Backed enums use their value (including `0`); pure enums use their name.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `...$values` | `string\|`[`Stringable`](https://www.php.net/manual/en/class.stringable.php)`\|`[`UnitEnum`](https://www.php.net/manual/en/class.unitenum.php) | Trusted raw HTML content to be appended. |

**Returns**

`static`: New instance with appended raw HTML content.