# HasSrc

> Provides an immutable API for the src attribute.

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

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

Used by 1 type:

- [`UIAwesome\Html\Metadata\Script`](/docs/extensions/html/reference/metadata/script/index.md)

Provides an immutable API for the `src` attribute.

See also: <https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/src>.

## Methods

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

## Method details

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

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

Sets the `src` attribute.

Specifies the resource URL.

**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` | Resource URL, or `null` to remove the attribute. |

**Returns**

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