Skip to content
PHP Ecosystem
Explore

BaseHtml

API reference › HTML Core › Base › BaseHtml

abstract classUIAwesome\Html\Core\Base\BaseHtml
Sourcesrc/Base/BaseHtml.php
1 subclass

Provides the base implementation for rendering HTML tags.

See also: https://developer.mozilla.org/en-US/docs/Glossary/Block-level_content, https://developer.mozilla.org/en-US/docs/Glossary/Inline-level_content, https://developer.mozilla.org/en-US/docs/Glossary/Void_element, https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements#main_root, https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements#table_content.

MethodDescriptionDefined by
begin() staticReturns the opening tag for a block element.BaseHtml
element() staticReturns a complete HTML element string.BaseHtml
end() staticReturns the closing tag for a block element.BaseHtml
inline() staticReturns an inline HTML element string.BaseHtml
void() staticReturns a void HTML element string.BaseHtml
public static function begin(BackedEnum $tag, array $attributes = []): string

Returns the opening tag for a block element.

Parameters

ParameterTypeDescription
$tagBackedEnumTag enumeration instance.
$attributesarrayAssociative array of HTML attributes.

Returns

string: Rendered opening tag string with attributes. The pre and textarea opening tags do not add a newline. Callers must supply a protective LF before streamed content starting with LF or CR (including CRLF); the opening tag cannot inspect future content. Block for valid block-level tags. Lists for valid list-level tags. Root for valid root-level tags. Table for valid table-level tags.

public static function element(BackedEnum $tag, string $content, array $attributes = [], bool $encode = false): string

Returns a complete HTML element string.

Parameters

ParameterTypeDescription
$tagBackedEnumTag enumeration instance.
$contentstringContent to be rendered inside the tag.
$attributesarrayAssociative array of HTML attributes.
$encodeboolWhether to encode the content for HTML output.

Returns

string: Rendered HTML element string. The pre and textarea elements do not receive presentation newlines around nonempty content. A protective LF is added only when their content starts with LF or CR (including CRLF). HTML normalizes CR/CRLF to LF before ignoring the first newline; the supplied content bytes are not normalized here. Block for valid block-level tags. Inline for valid inline-level tags. Lists for valid list-level tags. Root for valid root-level tags. Table for valid table-level tags. For void tags, use Html::void().

public static function end(BackedEnum $tag): string

Returns the closing tag for a block element.

Parameters

ParameterTypeDescription
$tagBackedEnumTag enumeration instance.

Returns

string: Rendered closing tag string. No presentation newline is added before pre or textarea closing tags, so streamed content stays intact. Block for valid block-level tags. Lists for valid list-level tags. Root for valid root-level tags. Table for valid table-level tags.

public static function inline(BackedEnum $tag, string $content, array $attributes = [], bool $encode = false): string

Returns an inline HTML element string.

Parameters

ParameterTypeDescription
$tagBackedEnumInline tag enumeration instance.
$contentstringContent to be rendered inside the tag.
$attributesarrayAssociative array of HTML attributes.
$encodeboolWhether to encode the content for HTML output.

Returns

string: Rendered inline HTML element string. Inline for valid inline-level tags.

public static function void(BackedEnum $tag, array $attributes = []): string

Returns a void HTML element string.

Parameters

ParameterTypeDescription
$tagBackedEnumVoid tag enumeration instance.
$attributesarrayAssociative array of HTML attributes.

Returns

string: Rendered void HTML element string. Voids for valid void-level tags.