# Html

> Html provides a set of static methods for generating commonly used HTML tags.

[API reference](/docs/api/index.md) › [yii](/docs/api/yii/index.md) › [helpers](/docs/api/yii/helpers/index.md) › Html

| class | `yii\helpers\Html` |
| --- | --- |
| Extends | [`BaseHtml`](/docs/api/yii/helpers/basehtml/index.md) |
| Since | 2.0 |
| Source | [`framework/helpers/Html.php`](https://github.com/yiisoft/yii2/blob/22.0/framework/helpers/Html.php#L23) |

1 subclass:

- [`yii2\extensions\bootstrap6\BaseHtml`](/docs/extensions/bootstrap6/reference/basehtml/index.md)

Html provides a set of static methods for generating commonly used HTML tags.

Nearly all of the methods in this class allow setting additional html attributes for the html
tags they generate. You can specify, for example, `class`, `style` or `id` for an html element
using the `$options` parameter. See the documentation of the [`tag()`](/docs/api/yii/helpers/basehtml/index.md#method-tag) method for more details.

For more details and usage information on Html, see the [guide article on html helpers](/docs/guide/helper-html/index.md).

## Properties

| Property | Type | Description | Defined by |
| --- | --- | --- | --- |
| <span id="property-attributeOrder"></span>[`$attributeOrder`](/docs/api/yii/helpers/basehtml/index.md#property-attributeOrder) static | `array` | The preferred order of attributes in a tag. Default: `['type', 'id', 'class', 'name', 'value', 'href', 'src', 'srcset', 'form', 'action', 'method', 'selected', 'checked', 'readonly', 'disabled', 'multiple', 'size', 'maxlength', 'width', 'height', 'rows', 'cols', 'alt', 'title', 'rel', 'media']`. | [`BaseHtml`](/docs/api/yii/helpers/basehtml/index.md) |
| <span id="property-attributeRegex"></span>[`$attributeRegex`](/docs/api/yii/helpers/basehtml/index.md#property-attributeRegex) static | `string` | Regular expression used for attribute name validation. Default: `'/(^\|.*\])([\w\.\+]+)(\[.*\|$)/u'`. Available since 2.0.12. | [`BaseHtml`](/docs/api/yii/helpers/basehtml/index.md) |
| <span id="property-dataAttributes"></span>[`$dataAttributes`](/docs/api/yii/helpers/basehtml/index.md#property-dataAttributes) static | `array` | List of tag attributes that should be specially handled when their values are of array type. Default: `['aria', 'data', 'data-ng', 'ng']`. Available since 2.0.3. | [`BaseHtml`](/docs/api/yii/helpers/basehtml/index.md) |
| <span id="property-normalizeClassAttribute"></span>[`$normalizeClassAttribute`](/docs/api/yii/helpers/basehtml/index.md#property-normalizeClassAttribute) static | `bool` | Whether to removes duplicate class names in tag attribute `class` Default: `false`. Available since 2.0.44. | [`BaseHtml`](/docs/api/yii/helpers/basehtml/index.md) |
| <span id="property-voidElements"></span>[`$voidElements`](/docs/api/yii/helpers/basehtml/index.md#property-voidElements) static | `array` | List of void elements (element name => 1) Default: `['area' => 1, 'base' => 1, 'br' => 1, 'col' => 1, 'command' => 1, 'embed' => 1, 'hr' => 1, 'img' => 1, 'input' => 1, 'keygen' => 1, 'link' => 1, 'meta' => 1, 'param' => 1, 'source' => 1, 'track' => 1, 'wbr' => 1]`. | [`BaseHtml`](/docs/api/yii/helpers/basehtml/index.md) |

## Methods

| Method | Description | Defined by |
| --- | --- | --- |
| <span id="method-a"></span>[`a()`](/docs/api/yii/helpers/basehtml/index.md#method-a) static | Generates a hyperlink tag. | [`BaseHtml`](/docs/api/yii/helpers/basehtml/index.md) |
| <span id="method-activeCheckbox"></span>[`activeCheckbox()`](/docs/api/yii/helpers/basehtml/index.md#method-activeCheckbox) static | Generates a checkbox tag together with a label for the given model attribute. | [`BaseHtml`](/docs/api/yii/helpers/basehtml/index.md) |
| <span id="method-activeCheckboxList"></span>[`activeCheckboxList()`](/docs/api/yii/helpers/basehtml/index.md#method-activeCheckboxList) static | Generates a list of checkboxes. | [`BaseHtml`](/docs/api/yii/helpers/basehtml/index.md) |
| <span id="method-activeDropDownList"></span>[`activeDropDownList()`](/docs/api/yii/helpers/basehtml/index.md#method-activeDropDownList) static | Generates a drop-down list for the given model attribute. | [`BaseHtml`](/docs/api/yii/helpers/basehtml/index.md) |
| <span id="method-activeFileInput"></span>[`activeFileInput()`](/docs/api/yii/helpers/basehtml/index.md#method-activeFileInput) static | Generates a file input tag for the given model attribute. | [`BaseHtml`](/docs/api/yii/helpers/basehtml/index.md) |
| <span id="method-activeHiddenInput"></span>[`activeHiddenInput()`](/docs/api/yii/helpers/basehtml/index.md#method-activeHiddenInput) static | Generates a hidden input tag for the given model attribute. | [`BaseHtml`](/docs/api/yii/helpers/basehtml/index.md) |
| <span id="method-activeHint"></span>[`activeHint()`](/docs/api/yii/helpers/basehtml/index.md#method-activeHint) static | Generates a hint tag for the given model attribute. | [`BaseHtml`](/docs/api/yii/helpers/basehtml/index.md) |
| <span id="method-activeInput"></span>[`activeInput()`](/docs/api/yii/helpers/basehtml/index.md#method-activeInput) static | Generates an input tag for the given model attribute. | [`BaseHtml`](/docs/api/yii/helpers/basehtml/index.md) |
| <span id="method-activeLabel"></span>[`activeLabel()`](/docs/api/yii/helpers/basehtml/index.md#method-activeLabel) static | Generates a label tag for the given model attribute. | [`BaseHtml`](/docs/api/yii/helpers/basehtml/index.md) |
| <span id="method-activeListBox"></span>[`activeListBox()`](/docs/api/yii/helpers/basehtml/index.md#method-activeListBox) static | Generates a list box. | [`BaseHtml`](/docs/api/yii/helpers/basehtml/index.md) |
| <span id="method-activePasswordInput"></span>[`activePasswordInput()`](/docs/api/yii/helpers/basehtml/index.md#method-activePasswordInput) static | Generates a password input tag for the given model attribute. | [`BaseHtml`](/docs/api/yii/helpers/basehtml/index.md) |
| <span id="method-activeRadio"></span>[`activeRadio()`](/docs/api/yii/helpers/basehtml/index.md#method-activeRadio) static | Generates a radio button tag together with a label for the given model attribute. | [`BaseHtml`](/docs/api/yii/helpers/basehtml/index.md) |
| <span id="method-activeRadioList"></span>[`activeRadioList()`](/docs/api/yii/helpers/basehtml/index.md#method-activeRadioList) static | Generates a list of radio buttons. | [`BaseHtml`](/docs/api/yii/helpers/basehtml/index.md) |
| <span id="method-activeTextarea"></span>[`activeTextarea()`](/docs/api/yii/helpers/basehtml/index.md#method-activeTextarea) static | Generates a textarea tag for the given model attribute. | [`BaseHtml`](/docs/api/yii/helpers/basehtml/index.md) |
| <span id="method-activeTextInput"></span>[`activeTextInput()`](/docs/api/yii/helpers/basehtml/index.md#method-activeTextInput) static | Generates a text input tag for the given model attribute. | [`BaseHtml`](/docs/api/yii/helpers/basehtml/index.md) |
| <span id="method-addCssClass"></span>[`addCssClass()`](/docs/api/yii/helpers/basehtml/index.md#method-addCssClass) static | Adds a CSS class (or several classes) to the specified options. | [`BaseHtml`](/docs/api/yii/helpers/basehtml/index.md) |
| <span id="method-addCssStyle"></span>[`addCssStyle()`](/docs/api/yii/helpers/basehtml/index.md#method-addCssStyle) static | Adds the specified CSS style to the HTML options. | [`BaseHtml`](/docs/api/yii/helpers/basehtml/index.md) |
| <span id="method-beginForm"></span>[`beginForm()`](/docs/api/yii/helpers/basehtml/index.md#method-beginForm) static | Generates a form start tag. | [`BaseHtml`](/docs/api/yii/helpers/basehtml/index.md) |
| <span id="method-beginTag"></span>[`beginTag()`](/docs/api/yii/helpers/basehtml/index.md#method-beginTag) static | Generates a start tag. | [`BaseHtml`](/docs/api/yii/helpers/basehtml/index.md) |
| <span id="method-button"></span>[`button()`](/docs/api/yii/helpers/basehtml/index.md#method-button) static | Generates a button tag. | [`BaseHtml`](/docs/api/yii/helpers/basehtml/index.md) |
| <span id="method-buttonInput"></span>[`buttonInput()`](/docs/api/yii/helpers/basehtml/index.md#method-buttonInput) static | Generates an input button. | [`BaseHtml`](/docs/api/yii/helpers/basehtml/index.md) |
| <span id="method-checkbox"></span>[`checkbox()`](/docs/api/yii/helpers/basehtml/index.md#method-checkbox) static | Generates a checkbox input. | [`BaseHtml`](/docs/api/yii/helpers/basehtml/index.md) |
| <span id="method-checkboxList"></span>[`checkboxList()`](/docs/api/yii/helpers/basehtml/index.md#method-checkboxList) static | Generates a list of checkboxes. | [`BaseHtml`](/docs/api/yii/helpers/basehtml/index.md) |
| <span id="method-csrfMetaTags"></span>[`csrfMetaTags()`](/docs/api/yii/helpers/basehtml/index.md#method-csrfMetaTags) static | Generates the meta tags containing CSRF token information. | [`BaseHtml`](/docs/api/yii/helpers/basehtml/index.md) |
| <span id="method-cssFile"></span>[`cssFile()`](/docs/api/yii/helpers/basehtml/index.md#method-cssFile) static | Generates a link tag that refers to an external CSS file. | [`BaseHtml`](/docs/api/yii/helpers/basehtml/index.md) |
| <span id="method-cssStyleFromArray"></span>[`cssStyleFromArray()`](/docs/api/yii/helpers/basehtml/index.md#method-cssStyleFromArray) static | Converts a CSS style array into a string representation. | [`BaseHtml`](/docs/api/yii/helpers/basehtml/index.md) |
| <span id="method-cssStyleToArray"></span>[`cssStyleToArray()`](/docs/api/yii/helpers/basehtml/index.md#method-cssStyleToArray) static | Converts a CSS style string into an array representation. | [`BaseHtml`](/docs/api/yii/helpers/basehtml/index.md) |
| <span id="method-decode"></span>[`decode()`](/docs/api/yii/helpers/basehtml/index.md#method-decode) static | Decodes special HTML entities back to the corresponding characters. | [`BaseHtml`](/docs/api/yii/helpers/basehtml/index.md) |
| <span id="method-dropDownList"></span>[`dropDownList()`](/docs/api/yii/helpers/basehtml/index.md#method-dropDownList) static | Generates a drop-down list. | [`BaseHtml`](/docs/api/yii/helpers/basehtml/index.md) |
| <span id="method-encode"></span>[`encode()`](/docs/api/yii/helpers/basehtml/index.md#method-encode) static | Encodes special characters into HTML entities. | [`BaseHtml`](/docs/api/yii/helpers/basehtml/index.md) |
| <span id="method-endForm"></span>[`endForm()`](/docs/api/yii/helpers/basehtml/index.md#method-endForm) static | Generates a form end tag. | [`BaseHtml`](/docs/api/yii/helpers/basehtml/index.md) |
| <span id="method-endTag"></span>[`endTag()`](/docs/api/yii/helpers/basehtml/index.md#method-endTag) static | Generates an end tag. | [`BaseHtml`](/docs/api/yii/helpers/basehtml/index.md) |
| <span id="method-error"></span>[`error()`](/docs/api/yii/helpers/basehtml/index.md#method-error) static | Generates a tag that contains the first validation error of the specified model attribute. | [`BaseHtml`](/docs/api/yii/helpers/basehtml/index.md) |
| <span id="method-errorSummary"></span>[`errorSummary()`](/docs/api/yii/helpers/basehtml/index.md#method-errorSummary) static | Generates a summary of the validation errors. | [`BaseHtml`](/docs/api/yii/helpers/basehtml/index.md) |
| <span id="method-escapeJsRegularExpression"></span>[`escapeJsRegularExpression()`](/docs/api/yii/helpers/basehtml/index.md#method-escapeJsRegularExpression) static | Escapes regular expression to use in JavaScript. | [`BaseHtml`](/docs/api/yii/helpers/basehtml/index.md) |
| <span id="method-fileInput"></span>[`fileInput()`](/docs/api/yii/helpers/basehtml/index.md#method-fileInput) static | Generates a file input field. | [`BaseHtml`](/docs/api/yii/helpers/basehtml/index.md) |
| <span id="method-getAttributeName"></span>[`getAttributeName()`](/docs/api/yii/helpers/basehtml/index.md#method-getAttributeName) static | Returns the real attribute name from the given attribute expression. | [`BaseHtml`](/docs/api/yii/helpers/basehtml/index.md) |
| <span id="method-getAttributeValue"></span>[`getAttributeValue()`](/docs/api/yii/helpers/basehtml/index.md#method-getAttributeValue) static | Returns the value of the specified attribute name or expression. | [`BaseHtml`](/docs/api/yii/helpers/basehtml/index.md) |
| <span id="method-getInputId"></span>[`getInputId()`](/docs/api/yii/helpers/basehtml/index.md#method-getInputId) static | Generates an appropriate input ID for the specified attribute name or expression. | [`BaseHtml`](/docs/api/yii/helpers/basehtml/index.md) |
| <span id="method-getInputIdByName"></span>[`getInputIdByName()`](/docs/api/yii/helpers/basehtml/index.md#method-getInputIdByName) static | Converts input name to ID. | [`BaseHtml`](/docs/api/yii/helpers/basehtml/index.md) |
| <span id="method-getInputName"></span>[`getInputName()`](/docs/api/yii/helpers/basehtml/index.md#method-getInputName) static | Generates an appropriate input name for the specified attribute name or expression. | [`BaseHtml`](/docs/api/yii/helpers/basehtml/index.md) |
| <span id="method-hiddenInput"></span>[`hiddenInput()`](/docs/api/yii/helpers/basehtml/index.md#method-hiddenInput) static | Generates a hidden input field. | [`BaseHtml`](/docs/api/yii/helpers/basehtml/index.md) |
| <span id="method-img"></span>[`img()`](/docs/api/yii/helpers/basehtml/index.md#method-img) static | Generates an image tag. | [`BaseHtml`](/docs/api/yii/helpers/basehtml/index.md) |
| <span id="method-input"></span>[`input()`](/docs/api/yii/helpers/basehtml/index.md#method-input) static | Generates an input type of the given type. | [`BaseHtml`](/docs/api/yii/helpers/basehtml/index.md) |
| <span id="method-jsFile"></span>[`jsFile()`](/docs/api/yii/helpers/basehtml/index.md#method-jsFile) static | Generates a script tag that refers to an external JavaScript file. | [`BaseHtml`](/docs/api/yii/helpers/basehtml/index.md) |
| <span id="method-label"></span>[`label()`](/docs/api/yii/helpers/basehtml/index.md#method-label) static | Generates a label tag. | [`BaseHtml`](/docs/api/yii/helpers/basehtml/index.md) |
| <span id="method-listBox"></span>[`listBox()`](/docs/api/yii/helpers/basehtml/index.md#method-listBox) static | Generates a list box. | [`BaseHtml`](/docs/api/yii/helpers/basehtml/index.md) |
| <span id="method-mailto"></span>[`mailto()`](/docs/api/yii/helpers/basehtml/index.md#method-mailto) static | Generates a mailto hyperlink. | [`BaseHtml`](/docs/api/yii/helpers/basehtml/index.md) |
| <span id="method-ol"></span>[`ol()`](/docs/api/yii/helpers/basehtml/index.md#method-ol) static | Generates an ordered list. | [`BaseHtml`](/docs/api/yii/helpers/basehtml/index.md) |
| <span id="method-passwordInput"></span>[`passwordInput()`](/docs/api/yii/helpers/basehtml/index.md#method-passwordInput) static | Generates a password input field. | [`BaseHtml`](/docs/api/yii/helpers/basehtml/index.md) |
| <span id="method-radio"></span>[`radio()`](/docs/api/yii/helpers/basehtml/index.md#method-radio) static | Generates a radio button input. | [`BaseHtml`](/docs/api/yii/helpers/basehtml/index.md) |
| <span id="method-radioList"></span>[`radioList()`](/docs/api/yii/helpers/basehtml/index.md#method-radioList) static | Generates a list of radio buttons. | [`BaseHtml`](/docs/api/yii/helpers/basehtml/index.md) |
| <span id="method-removeCssClass"></span>[`removeCssClass()`](/docs/api/yii/helpers/basehtml/index.md#method-removeCssClass) static | Removes a CSS class from the specified options. | [`BaseHtml`](/docs/api/yii/helpers/basehtml/index.md) |
| <span id="method-removeCssStyle"></span>[`removeCssStyle()`](/docs/api/yii/helpers/basehtml/index.md#method-removeCssStyle) static | Removes the specified CSS style from the HTML options. | [`BaseHtml`](/docs/api/yii/helpers/basehtml/index.md) |
| <span id="method-renderSelectOptions"></span>[`renderSelectOptions()`](/docs/api/yii/helpers/basehtml/index.md#method-renderSelectOptions) static | Renders the option tags that can be used by [`dropDownList()`](/docs/api/yii/helpers/basehtml/index.md#method-dropDownList) and [`listBox()`](/docs/api/yii/helpers/basehtml/index.md#method-listBox). | [`BaseHtml`](/docs/api/yii/helpers/basehtml/index.md) |
| <span id="method-renderTagAttributes"></span>[`renderTagAttributes()`](/docs/api/yii/helpers/basehtml/index.md#method-renderTagAttributes) static | Renders the HTML tag attributes. | [`BaseHtml`](/docs/api/yii/helpers/basehtml/index.md) |
| <span id="method-resetButton"></span>[`resetButton()`](/docs/api/yii/helpers/basehtml/index.md#method-resetButton) static | Generates a reset button tag. | [`BaseHtml`](/docs/api/yii/helpers/basehtml/index.md) |
| <span id="method-resetInput"></span>[`resetInput()`](/docs/api/yii/helpers/basehtml/index.md#method-resetInput) static | Generates a reset input button. | [`BaseHtml`](/docs/api/yii/helpers/basehtml/index.md) |
| <span id="method-script"></span>[`script()`](/docs/api/yii/helpers/basehtml/index.md#method-script) static | Generates a script tag. | [`BaseHtml`](/docs/api/yii/helpers/basehtml/index.md) |
| <span id="method-style"></span>[`style()`](/docs/api/yii/helpers/basehtml/index.md#method-style) static | Generates a style tag. | [`BaseHtml`](/docs/api/yii/helpers/basehtml/index.md) |
| <span id="method-submitButton"></span>[`submitButton()`](/docs/api/yii/helpers/basehtml/index.md#method-submitButton) static | Generates a submit button tag. | [`BaseHtml`](/docs/api/yii/helpers/basehtml/index.md) |
| <span id="method-submitInput"></span>[`submitInput()`](/docs/api/yii/helpers/basehtml/index.md#method-submitInput) static | Generates a submit input button. | [`BaseHtml`](/docs/api/yii/helpers/basehtml/index.md) |
| <span id="method-tag"></span>[`tag()`](/docs/api/yii/helpers/basehtml/index.md#method-tag) static | Generates a complete HTML tag. | [`BaseHtml`](/docs/api/yii/helpers/basehtml/index.md) |
| <span id="method-textarea"></span>[`textarea()`](/docs/api/yii/helpers/basehtml/index.md#method-textarea) static | Generates a text area input. | [`BaseHtml`](/docs/api/yii/helpers/basehtml/index.md) |
| <span id="method-textInput"></span>[`textInput()`](/docs/api/yii/helpers/basehtml/index.md#method-textInput) static | Generates a text input field. | [`BaseHtml`](/docs/api/yii/helpers/basehtml/index.md) |
| <span id="method-ul"></span>[`ul()`](/docs/api/yii/helpers/basehtml/index.md#method-ul) static | Generates an unordered list. | [`BaseHtml`](/docs/api/yii/helpers/basehtml/index.md) |
| <span id="method-activeBooleanInput"></span>[`activeBooleanInput()`](/docs/api/yii/helpers/basehtml/index.md#method-activeBooleanInput) protected static | Generates a boolean input This method is mainly called by [`activeCheckbox()`](/docs/api/yii/helpers/basehtml/index.md#method-activeCheckbox) and [`activeRadio()`](/docs/api/yii/helpers/basehtml/index.md#method-activeRadio). | [`BaseHtml`](/docs/api/yii/helpers/basehtml/index.md) |
| <span id="method-activeListInput"></span>[`activeListInput()`](/docs/api/yii/helpers/basehtml/index.md#method-activeListInput) protected static | Generates a list of input fields. | [`BaseHtml`](/docs/api/yii/helpers/basehtml/index.md) |
| <span id="method-booleanInput"></span>[`booleanInput()`](/docs/api/yii/helpers/basehtml/index.md#method-booleanInput) protected static | Generates a boolean input. | [`BaseHtml`](/docs/api/yii/helpers/basehtml/index.md) |
| <span id="method-setActivePlaceholder"></span>[`setActivePlaceholder()`](/docs/api/yii/helpers/basehtml/index.md#method-setActivePlaceholder) protected static | Generate placeholder from model attribute label. | [`BaseHtml`](/docs/api/yii/helpers/basehtml/index.md) |