Html::tag()
Builds an HTML tag
Html::tag(string $name, array|string $content = '', array $attr = [ ], string|null $indent = null, int $level = 0): string
Parameters
Name | Type | Default | Description |
---|---|---|---|
$namerequired | string |
no default value | Tag name |
$content | array orstring |
''
|
Scalar value or array with multiple lines of content; self-closing tags are generated automatically based on the Html::isVoid() list |
$attr | array |
[ ]
|
An associative array with additional attributes for the tag |
$indent | string ornull |
null
|
Indentation string, defaults to two spaces or null for output on one line |
$level | int |
0
|
Indentation level |
Return type
string
The generated HTML
Parent class
Kirby\Cms\Html
inherited from Kirby\Toolkit\Html
Details
If you want to pass a string of HTML to the tag, you need an wrap it in an array:
$title = '<a href="#">Text</a>';
Html::tag('h1', [$title])