Reference

Guide

Html::tag()

Generates an Html tag with optional content and attributes

Html::tag(string $name, mixed $content = null, array $attr = [ ]): string

Parameters

Name Type Default Description
$name string

The name of the tag, i.e. a

$content mixed null

The content if availble. Pass null to generate a self-closing tag, Pass an empty string to generate empty content

$attr array [ ]

An associative array with additional attributes for the tag

Return type

string

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])

Inherited from

Kirby\Toolkit\Html

Source code

kirby/src/Toolkit/Html.php#L381