<input>: The Input (Form Input) element - HTML: HyperText Markup Language

<input>: The Input (Form Input) element
=======================================

The **`<input>`** HTML element is used to create interactive controls for web-based forms in order to accept data from the user; a wide variety of types of input data and control widgets are available, depending on the device and user agent. The `<input>` element is one of the most powerful and complex in all of HTML due to the sheer number of combinations of input types and attributes.

Try it
------

<input> types
-------------

How an `<input>` works varies considerably depending on the value of its `type` attribute, hence the different types are covered in their own separate reference pages. If this attribute is not specified, the default type adopted is `text`.

The available types are as follows:

| Type | Description | Basic Examples |
| --- | --- | --- |
| button | A push button with no default behavior displaying the value of the `value` attribute, empty by default. |
```
<input type="button" name="button" value="Button" />
```
 |
| checkbox | A check box allowing single values to be selected/deselected. |
```
<input type="checkbox" name="checkbox"/>
```
 |
| color | A control for specifying a color; opening a color picker when active in supporting browsers. |
```
<input type="color" name="color"/>
```
 |
| date |
 A control for entering a date (year, month, and day, with no time).
 Opens a date picker or numeric wheels for year, month, day when active
 in supporting browsers.
  |
```
<input type="date" name="date"/>
```
 |
| datetime-local |
 A control for entering a date and time, with no time zone. Opens a date
 picker or numeric wheels for date- and time-components when active in supporting browsers.
  |
```
<input type="datetime-local" name="datetime-local"/>
```
 |
| email |
 A field for editing an email address. Looks like a
 `text` input, but has validation parameters and relevant
 keyboard in supporting browsers and devices with dynamic keyboards.
  |
```
<input type="email" name="email"/>
```
 |
| file |
 A control that lets the user select a file.
 Use the `accept` attribute to define the types of files that the control can select.
  |
```
<input type="file" accept="image/\*, text/\*" name="file"/>
```
 |
| hidden |
 A control that is not displayed but whose value is submitted to the
 server. There is an example in the next column, but it's hidden!
  |
```
<input id="userId" name="userId" type="hidden" value="abc123">
```
 |
| image |
 A graphical `submit` button. Displays an image defined by the `src` attribute.
 The `alt` attribute displays if the image `src` is missing.
  |
```
<input type="image" name="image" src="" alt="image input"/>
```
 |
| month | A control for entering a month and year, with no time zone. |
```
<input type="month" name="month"/>
```
 |
| number |
 A control for entering a number. Displays a spinner and adds default
 validation. Displays a numeric keypad in some devices
 with dynamic keypads.
  |
```
<input type="number" name="number"/>
```
 |
| password |
 A single-line text field whose value is obscured.
 Will alert user if site is not secure.
  |
```
<input type="password" name="password"/>
```
 |
| radio | A radio button, allowing a single value to be selected out of multiple choices with the same `name` value. |
```
<input type="radio" name="radio"/>
```
 |
| range |
 A control for entering a number whose exact value is not important.
 Displays as a range widget defaulting to the middle value.
 Used in conjunction `min` and `max` to define the range of acceptable values.
  |
```
<input type="range" name="range" min="0" max="25"/>
```
 |
| reset | A button that resets the contents of the form to default values. Not recommended. |
```
<input type="reset" name="reset"/>
```
 |
| search |
 A single-line text field for entering search strings. Line-breaks are
 automatically removed from the input value. May include a delete icon in
 supporting browsers that can be used to clear the field. Displays a
 search icon instead of enter key on some devices with dynamic keypads.
  |
```
<input type="search" name="search"/>
```
 |
| submit | A button that submits the form. |
```
<input type="submit" name="submit"/>
```
 |
| tel |
 A control for entering a telephone number. Displays a telephone keypad
 in some devices with dynamic keypads.
  |
```
<input type="tel" name="tel"/>
```
 |
| text |
 The default value. A single-line text field. Line-breaks are
 automatically removed from the input value.
  |
```
<input type="text" name="text"/>
```
 |
| time | A control for entering a time value with no time zone. |
```
<input type="time" name="time"/>
```
 |
| url |
 A field for entering a URL. Looks like a `text` input, but
 has validation parameters and relevant keyboard in supporting browsers
 and devices with dynamic keyboards.
  |
```
<input type="url" name="url"/>
```
 |
| week | A control for entering a date consisting of a week-year number and a week number with no time zone. |
```
<input type="week" name="week"/>
```
 |
| Obsolete values |
| `datetime`
Deprecated
 | A control for entering a date and time (hour, minute, second, and fraction of a second) based on UTC time zone. |
```
<input type="datetime" name="datetime"/>
```
 |

Attributes
----------

The `<input>` element is so powerful because of its attributes; the `type` attribute, described with examples above, being the most important. Since every `<input>` element, regardless of type, is based on the `HTMLInputElement` interface, they technically share the exact same set of attributes. However, in reality, most attributes have an effect on only a specific subset of input types. In addition, the way some attributes impact an input depends on the input type, impacting different input types in different ways.

This section provides a table listing all the attributes with a brief description. This table is followed by a list describing each attribute in greater detail, along with which input types they are associated with. Those that are common to most or all input types are defined in greater detail below. Attributes that are unique to particular input types—or attributes which are common to all input types but have special behaviors when used on a given input type—are instead documented on those types' pages.

Attributes for the `<input>` element include the global HTML attributes and additionally:

| Attribute | Type or Types | Description |
| --- | --- | --- |
| `accept` | `file` | Hint for expected file type in file upload controls |
| `alt` | `image` | alt attribute for the image type. Required for accessibility |
| `autocapitalize` | all except `url`, `email`, and `password` | Controls automatic capitalization in inputted text. |
| `autocomplete` | all except `checkbox`, `radio`, and buttons | Hint for form autofill feature |
| `capture` | `file` | Media capture input method in file upload controls |
| `checked` | `checkbox`, `radio` | Whether the command or control is checked |
| `dirname` | `hidden`, `text`, `search`, `url`, `tel`, `email` | Name of form field to use for sending the element's directionality in form submission |
| `disabled` | all | Whether the form control is disabled |
| `form` | all | Associates the control with a form element |
| `formaction` | `image`, `submit` | URL to use for form submission |
| `formenctype` | `image`, `submit` | Form data set encoding type to use for form submission |
| `formmethod` | `image`, `submit` | HTTP method to use for form submission |
| `formnovalidate` | `image`, `submit` | Bypass form control validation for form submission |
| `formtarget` | `image`, `submit` | Browsing context for form submission |
| `height` | `image` | Same as height attribute for `<img>`; vertical dimension |
| `list` | all except `hidden`, `password`, `checkbox`, `radio`, and buttons | Value of the id attribute of the `<datalist>` of autocomplete options |
| `max` | `date`, `month`, `week`, `time`, `datetime-local`, `number`, `range` | Maximum value |
| `maxlength` | `text`, `search`, `url`, `tel`, `email`, `password` | Maximum length (number of characters) of `value` |
| `min` | `date`, `month`, `week`, `time`, `datetime-local`, `number`, `range` | Minimum value |
| `minlength` | `text`, `search`, `url`, `tel`, `email`, `password` | Minimum length (number of characters) of `value` |
| `multiple` | `email`, `file` | Boolean. Whether to allow multiple values |
| `name` | all | Name of the form control. Submitted with the form as part of a name/value pair |
| `pattern` | `text`, `search`, `url`, `tel`, `email`, `password` | Pattern the `value` must match to be valid |
| `placeholder` | `text`, `search`, `url`, `tel`, `email`, `password`, `number` | Text that appears in the form control when it has no value set |
| `popovertarget` | `button` | Designates an `<input type="button">` as a control for a popover element |
| `popovertargetaction` | `button` | Specifies the action that a popover control should perform |
| `readonly` | all except `hidden`, `range`, `color`, `checkbox`, `radio`, and buttons | Boolean. The value is not editable |
| `required` | all except `hidden`, `range`, `color`, and buttons | Boolean. A value is required or must be checked for the form to be submittable |
| `size` | `text`, `search`, `url`, `tel`, `email`, `password` | Size of the control |
| `src` | `image` | Same as `src` attribute for `<img>`; address of image resource |
| `step` | `date`, `month`, `week`, `time`, `datetime-local`, `number`, `range` | Incremental values that are valid |
| `type` | all | Type of form control |
| `value` | all except `image` | The initial value of the control |
| `width` | `image` | Same as `width` attribute for `<img>` |

A few additional non-standard attributes are listed following the descriptions of the standard attributes.

### Individual attributes

`accept`

Valid for the `file` input type only, the `accept` attribute defines which file types are selectable in a `file` upload control. See the file input type.

`alt`

Valid for the `image` button only, the `alt` attribute provides alternative text for the image, displaying the value of the attribute if the image `src` is missing or otherwise fails to load. See the image input type.

`autocapitalize`

Controls whether inputted text is automatically capitalized and, if so, in what manner. See the `autocapitalize` global attribute page for more information.

`autocomplete`

(**Not** a Boolean attribute!) The `autocomplete` attribute takes as its value a space-separated string that describes what, if any, type of autocomplete functionality the input should provide. A typical implementation of autocomplete recalls previous values entered in the same input field, but more complex forms of autocomplete can exist. For instance, a browser could integrate with a device's contacts list to autocomplete `email` addresses in an email input field. See `autocomplete` for permitted values.

The `autocomplete` attribute is valid on `hidden`, `text`, `search`, `url`, `tel`, `email`, `date`, `month`, `week`, `time`, `datetime-local`, `number`, `range`, `color`, and `password`. This attribute has no effect on input types that do not return numeric or text data, being valid for all input types except `checkbox`, `radio`, `file`, or any of the button types.

See the `autocomplete` attribute for additional information, including information on password security and how `autocomplete` is slightly different for `hidden` than for other input types.

`autofocus`

A Boolean attribute which, if present, indicates that the input should automatically have focus when the page has finished loading (or when the `<dialog>` containing the element has been displayed).

**Note:** An element with the `autofocus` attribute may gain focus before the `DOMContentLoaded` event is fired.

No more than one element in the document may have the `autofocus` attribute. If put on more than one element, the first one with the attribute receives focus.

The `autofocus` attribute cannot be used on inputs of type `hidden`, since hidden inputs cannot be focused.

**Warning:** Automatically focusing a form control can confuse visually-impaired people using screen-reading technology and people with cognitive impairments. When `autofocus` is assigned, screen-readers "teleport" their user to the form control without warning them beforehand.

Use careful consideration for accessibility when applying the `autofocus` attribute. Automatically focusing on a control can cause the page to scroll on load. The focus can also cause dynamic keyboards to display on some touch devices. While a screen reader will announce the label of the form control receiving focus, the screen reader will not announce anything before the label, and the sighted user on a small device will equally miss the context created by the preceding content.

`capture`

Introduced in the HTML Media Capture specification and valid for the `file` input type only, the `capture` attribute defines which media—microphone, video, or camera—should be used to capture a new file for upload with `file` upload control in supporting scenarios. See the file input type.

`checked`

Valid for both `radio` and `checkbox` types, `checked` is a Boolean attribute. If present on a `radio` type, it indicates that the radio button is the currently selected one in the group of same-named radio buttons. If present on a `checkbox` type, it indicates that the checkbox is checked by default (when the page loads). It does *not* indicate whether this checkbox is currently checked: if the checkbox's state is changed, this content attribute does not reflect the change. (Only the `HTMLInputElement`'s `checked` IDL attribute is updated.)

**Note:** Unlike other input controls, a checkboxes and radio buttons value are only included in the submitted data if they are currently `checked`. If they are, the name and the value(s) of the checked controls are submitted.

For example, if a checkbox whose `name` is `fruit` has a `value` of `cherry`, and the checkbox is checked, the form data submitted will include `fruit=cherry`. If the checkbox isn't active, it isn't listed in the form data at all. The default `value` for checkboxes and radio buttons is `on`.

`dirname`

Valid for `hidden`, `text`, `search`, `url`, `tel`, and `email` input types, the `dirname` attribute enables the submission of the directionality of the element. When included, the form control will submit with two name/value pairs: the first being the `name` and `value`, and the second being the value of the `dirname` attribute as the name, with a value of `ltr` or `rtl` as set by the browser.

```html
<form action="page.html" method="post">
  <label>
    Fruit:
    <input type="text" name="fruit" dirname="fruit-dir" value="cherry" />
  </label>
  <input type="submit" />
</form>
<!-- page.html?fruit=cherry&fruit-dir=ltr -->
```

 When the form above is submitted, the input cause both the `name` / `value` pair of `fruit=cherry` and the `dirname` / direction pair of `fruit-dir=ltr` to be sent.
 For more information, see the `dirname` attribute.

`disabled`

A Boolean attribute which, if present, indicates that the user should not be able to interact with the input. Disabled inputs are typically rendered with a dimmer color or using some other form of indication that the field is not available for use.

Specifically, disabled inputs do not receive the `click` event, and disabled inputs are not submitted with the form.

**Note:** Although not required by the specification, Firefox will by default persist the dynamic disabled state of an `<input>` across page loads. Use the `autocomplete` attribute to control this feature.

`form`

A string specifying the `<form>` element with which the input is associated (that is, its **form owner**). This string's value, if present, must match the `id` of a `<form>` element in the same document. If this attribute isn't specified, the `<input>` element is associated with the nearest containing form, if any.

The `form` attribute lets you place an input anywhere in the document but have it included with a form elsewhere in the document.

**Note:** An input can only be associated with one form.

`formaction`

Valid for the `image` and `submit` input types only. See the submit input type for more information.

`formenctype`

Valid for the `image` and `submit` input types only. See the submit input type for more information.

`formmethod`

Valid for the `image` and `submit` input types only. See the submit input type for more information.

`formnovalidate`

Valid for the `image` and `submit` input types only. See the submit input type for more information.

`formtarget`

Valid for the `image` and `submit` input types only. See the submit input type for more information.

`height`

Valid for the `image` input button only, the `height` is the height of the image file to display to represent the graphical submit button. See the image input type.

`id`

Global attribute valid for all elements, including all the input types, it defines a unique identifier (ID) which must be unique in the whole document. Its purpose is to identify the element when linking. The value is used as the value of the `<label>`'s `for` attribute to link the label with the form control. See `<label>`.

`inputmode`

Global value valid for all elements, it provides a hint to browsers as to the type of virtual keyboard configuration to use when editing this element or its contents. Values include `none`, `text`, `tel`, `url`, `email`, `numeric`, `decimal`, and `search`.

`list`

The value given to the `list` attribute should be the `id` of a `<datalist>` element located in the same document. The `<datalist>` provides a list of predefined values to suggest to the user for this input. Any values in the list that are not compatible with the `type` are not included in the suggested options. The values provided are suggestions, not requirements: users can select from this predefined list or provide a different value.

It is valid on `text`, `search`, `url`, `tel`, `email`, `date`, `month`, `week`, `time`, `datetime-local`, `number`, `range`, and `color`.

Per the specifications, the `list` attribute is not supported by the `hidden`, `password`, `checkbox`, `radio`, `file`, or any of the button types.

Depending on the browser, the user may see a custom color palette suggested, tic marks along a range, or even an input that opens like a `<select>` but allows for non-listed values. Check out the browser compatibility table for the other input types.

See the `<datalist>` element.

`max`

Valid for `date`, `month`, `week`, `time`, `datetime-local`, `number`, and `range`, it defines the greatest value in the range of permitted values. If the `value` entered into the element exceeds this, the element fails constraint validation. If the value of the `max` attribute isn't a number, then the element has no maximum value.

There is a special case: if the data type is periodic (such as for dates or times), the value of `max` may be lower than the value of `min`, which indicates that the range may wrap around; for example, this allows you to specify a time range from 10 PM to 4 AM.

`maxlength`

Valid for `text`, `search`, `url`, `tel`, `email`, and `password`, it defines the maximum string length (measured in UTF-16 code units) that the user can enter into the field. This must be an integer value of 0 or higher. If no `maxlength` is specified, or an invalid value is specified, the field has no maximum length. This value must also be greater than or equal to the value of `minlength`.

The input will fail constraint validation if the length of the text entered into the field is greater than `maxlength` UTF-16 code units long. By default, browsers prevent users from entering more characters than allowed by the `maxlength` attribute. See Client-side validation for more information.

`min`

Valid for `date`, `month`, `week`, `time`, `datetime-local`, `number`, and `range`, it defines the most negative value in the range of permitted values. If the `value` entered into the element is less than this, the element fails constraint validation. If the value of the `min` attribute isn't a number, then the element has no minimum value.

This value must be less than or equal to the value of the `max` attribute. If the `min` attribute is present but is not specified or is invalid, no `min` value is applied. If the `min` attribute is valid and a non-empty value is less than the minimum allowed by the `min` attribute, constraint validation will prevent form submission. See Client-side validation for more information.

There is a special case: if the data type is periodic (such as for dates or times), the value of `max` may be lower than the value of `min`, which indicates that the range may wrap around; for example, this allows you to specify a time range from 10 PM to 4 AM.

`minlength`

Valid for `text`, `search`, `url`, `tel`, `email`, and `password`, it defines the minimum string length (measured in UTF-16 code units) that the user can enter into the entry field. This must be a non-negative integer value smaller than or equal to the value specified by `maxlength`. If no `minlength` is specified, or an invalid value is specified, the input has no minimum length.

The input will fail constraint validation if the length of the text entered into the field is fewer than `minlength` UTF-16 code units long, preventing form submission. See Client-side validation for more information.

`multiple`

The Boolean `multiple` attribute, if set, means the user can enter comma separated email addresses in the email widget or can choose more than one file with the `file` input. See the email and file input type.

`name`

A string specifying a name for the input control. This name is submitted along with the control's value when the form data is submitted.

Consider the `name` a required attribute (even though it's not). If an input has no `name` specified, or `name` is empty, the input's value is not submitted with the form! (Disabled controls, unchecked radio buttons, unchecked checkboxes, and reset buttons are also not sent.)

There are two special cases:

1. `_charset_` : If used as the name of an `<input>` element of type hidden, the input's `value` is automatically set by the user agent to the character encoding being used to submit the form.
2. `isindex`: For historical reasons, the name `isindex` is not allowed.

The `name` attribute creates a unique behavior for radio buttons.

Only one radio button in a same-named group of radio buttons can be checked at a time. Selecting any radio button in that group automatically deselects any currently-selected radio button in the same group. The value of that one checked radio button is sent along with the name if the form is submitted,

When tabbing into a series of same-named group of radio buttons, if one is checked, that one will receive focus. If they aren't grouped together in source order, if one of the group is checked, tabbing into the group starts when the first one in the group is encountered, skipping all those that aren't checked. In other words, if one is checked, tabbing skips the unchecked radio buttons in the group. If none are checked, the radio button group receives focus when the first button in the same name group is reached.

Once one of the radio buttons in a group has focus, using the arrow keys will navigate through all the radio buttons of the same name, even if the radio buttons are not grouped together in the source order.

When an input element is given a `name`, that name becomes a property of the owning form element's `HTMLFormElement.elements` property. If you have an input whose `name` is set to `guest` and another whose `name` is `hat-size`, the following code can be used:

```js
let form = document.querySelector("form");

let guestName = form.elements.guest;
let hatSize = form.elements["hat-size"];
```

When this code has run, `guestName` will be the `HTMLInputElement` for the `guest` field, and `hatSize` the object for the `hat-size` field.

**Warning:** Avoid giving form elements a `name` that corresponds to a built-in property of the form, since you would then override the predefined property or method with this reference to the corresponding input.

`pattern`

Valid for `text`, `search`, `url`, `tel`, `email`, and `password`, the `pattern` attribute defines a regular expression that the input's `value` must match in order for the value to pass constraint validation. It must be a valid JavaScript regular expression, as used by the `RegExp` type, and as documented in our guide on regular expressions; the `'u'` flag is specified when compiling the regular expression, so that the pattern is treated as a sequence of Unicode code points, instead of as ASCII. No forward slashes should be specified around the pattern text.

If the `pattern` attribute is present but is not specified or is invalid, no regular expression is applied and this attribute is ignored completely. If the pattern attribute is valid and a non-empty value does not match the pattern, constraint validation will prevent form submission.

**Note:** If using the `pattern` attribute, inform the user about the expected format by including explanatory text nearby. You can also include a `title` attribute to explain what the requirements are to match the pattern; most browsers will display this title as a tooltip. The visible explanation is required for accessibility. The tooltip is an enhancement.

See Client-side validation for more information.

`placeholder`

Valid for `text`, `search`, `url`, `tel`, `email`, `password`, and `number`, the `placeholder` attribute provides a brief hint to the user as to what kind of information is expected in the field. It should be a word or short phrase that provides a hint as to the expected type of data, rather than an explanation or prompt. The text *must not* include carriage returns or line feeds. So for example if a field is expected to capture a user's first name, and its label is "First Name", a suitable placeholder might be "e.g. Mustafa".

**Note:** The `placeholder` attribute is not as semantically useful as other ways to explain your form, and can cause unexpected technical issues with your content. See Labels for more information.

`popovertarget`

Turns an `<input type="button">` element into a popover control button; takes the ID of the popover element to control as its value. See the Popover API landing page for more details.

`popovertargetaction`

Specifies the action to be performed on a popover element being controlled by a control `<input type="button">`. Possible values are:

`"hide"`

The button will hide a shown popover. If you try to hide an already hidden popover, no action will be taken.

`"show"`

The button will show a hidden popover. If you try to show an already showing popover, no action will be taken.

`"toggle"`

The button will toggle a popover between showing and hidden. If the popover is hidden, it will be shown; if the popover is showing, it will be hidden. If `popovertargetaction` is omitted, `"toggle"` is the default action that will be performed by the control button.

`readonly`

A Boolean attribute which, if present, indicates that the user should not be able to edit the value of the input. The `readonly` attribute is supported by the `text`, `search`, `url`, `tel`, `email`, `date`, `month`, `week`, `time`, `datetime-local`, `number`, and `password` input types.

See the HTML attribute: `readonly` for more information.

`required`

`required` is a Boolean attribute which, if present, indicates that the user must specify a value for the input before the owning form can be submitted. The `required` attribute is supported by `text`, `search`, `url`, `tel`, `email`, `date`, `month`, `week`, `time`, `datetime-local`, `number`, `password`, `checkbox`, `radio`, and `file` inputs.

See Client-side validation and the HTML attribute: `required` for more information.

`size`

Valid for `email`, `password`, `tel`, `url`, and `text`, the `size` attribute specifies how much of the input is shown. Basically creates same result as setting CSS `width` property with a few specialities. The actual unit of the value depends on the input type. For `password` and `text`, it is a number of characters (or `em` units) with a default value of `20`, and for others, it is pixels (or `px` units). CSS `width` takes precedence over the `size` attribute.

`src`

Valid for the `image` input button only, the `src` is string specifying the URL of the image file to display to represent the graphical submit button. See the image input type.

`step`

Valid for `date`, `month`, `week`, `time`, `datetime-local`, `number`, and `range`, the `step` attribute is a number that specifies the granularity that the value must adhere to.

If not explicitly included:

* `step` defaults to 1 for `number` and `range`.
* Each date/time input type has a default `step` value appropriate for the type; see the individual input pages: `date`, `datetime-local`, `month`, `time`, and `week`.

The value must be a positive number—integer or float—or the special value `any`, which means no stepping is implied, and any value is allowed (barring other constraints, such as `min` and `max`).

If `any` is not explicitly set, valid values for the `number`, date/time input types, and `range` input types are equal to the basis for stepping — the `min` value and increments of the step value, up to the `max` value, if specified.

For example, if you have `<input type="number" min="10" step="2">`, then any even integer, `10` or greater, is valid. If omitted, `<input type="number">`, any integer is valid, but floats (like `4.2`) are not valid, because `step` defaults to `1`. For `4.2` to be valid, `step` would have had to be set to `any`, 0.1, 0.2, or any the `min` value would have had to be a number ending in `.2`, such as `<input type="number" min="-5.2">`

**Note:** When the data entered by the user doesn't adhere to the stepping configuration, the value is considered invalid in constraint validation and will match the `:invalid` pseudoclass.

See Client-side validation for more information.

`tabindex`

Global attribute valid for all elements, including all the input types, an integer attribute indicating if the element can take input focus (is focusable), if it should participate to sequential keyboard navigation. As all input types except for input of type hidden are focusable, this attribute should not be used on form controls, because doing so would require the management of the focus order for all elements within the document with the risk of harming usability and accessibility if done incorrectly.

`title`

Global attribute valid for all elements, including all input types, containing a text representing advisory information related to the element it belongs to. Such information can typically, but not necessarily, be presented to the user as a tooltip. The title should NOT be used as the primary explanation of the purpose of the form control. Instead, use the `<label>` element with a `for` attribute set to the form control's `id` attribute. See Labels below.

`type`

A string specifying the type of control to render. For example, to create a checkbox, a value of `checkbox` is used. If omitted (or an unknown value is specified), the input type `text` is used, creating a plaintext input field.

Permitted values are listed in Input types above.

`value`

The input control's value. When specified in the HTML, this is the initial value, and from then on it can be altered or retrieved at any time using JavaScript to access the respective `HTMLInputElement` object's `value` property. The `value` attribute is always optional, though should be considered mandatory for `checkbox`, `radio`, and `hidden`.

`width`

Valid for the `image` input button only, the `width` is the width of the image file to display to represent the graphical submit button. See the image input type.

### Non-standard attributes

The following non-standard attributes are also available on some browsers. As a general rule, you should avoid using them unless it can't be helped.

| Attribute | Description |
| --- | --- |
| `autocorrect` | A string indicating whether autocorrect is `on` or `off`. **Safari only.** |
| `incremental` |
 Whether or not to send repeated `search`
 events to allow updating live search results while the user is still editing the value of the field.
 **WebKit and Blink only (Safari, Chrome, Opera, etc.).** |
| `mozactionhint`
Deprecated
 |
 A string indicating the type of action that will be taken when the user
 presses the `Enter` or `Return` key while editing the
 field; this is used to determine an appropriate label for that key on a
 virtual keyboard. **Since this attribute is deprecated, use `enterkeyhint` instead.**
 |
| `orient` | Sets the orientation of the range slider. **Firefox only**. |
| `results` | The maximum number of items that should be displayed in the drop-down list of previous search queries. **Safari only.** |
| `webkitdirectory` | A Boolean indicating whether to only allow the user to choose a directory (or directories, if `multiple` is also present) |

`autocorrect`
Non-standard

(Safari only). A string which indicates whether to activate automatic correction while the user is editing this field. Permitted values are:

`on`

Enable automatic correction of typos, as well as processing of text substitutions if any are configured.

`off`

Disable automatic correction and text substitutions.

`incremental`
Non-standard

The Boolean attribute `incremental` is a WebKit and Blink extension (so supported by Safari, Opera, Chrome, etc.) which, if present, tells the user agent to process the input as a live search. As the user edits the value of the field, the user agent sends `search` events to the `HTMLInputElement` object representing the search box. This allows your code to update the search results in real time as the user edits the search.

If `incremental` is not specified, the `search` event is only sent when the user explicitly initiates a search (such as by pressing the `Enter` or `Return` key while editing the field).

The `search` event is rate-limited so that it is not sent more frequently than an implementation-defined interval.

`orient`
Non-standard

Similar to the -moz-orient non-standard CSS property impacting the `<progress>` and `<meter>` elements, the `orient` attribute defines the orientation of the range slider. Values include `horizontal`, meaning the range is rendered horizontally, and `vertical`, where the range is rendered vertically.

`results`
Non-standard

The `results` attribute—supported only by Safari—is a numeric value that lets you override the maximum number of entries to be displayed in the `<input>` element's natively-provided drop-down menu of previous search queries.

The value must be a non-negative decimal number. If not provided, or an invalid value is given, the browser's default maximum number of entries is used.

`webkitdirectory`
Non-standard

The Boolean `webkitdirectory` attribute, if present, indicates that only directories should be available to be selected by the user in the file picker interface. See `HTMLInputElement.webkitdirectory` for additional details and examples.

Though originally implemented only for WebKit-based browsers, `webkitdirectory` is also usable in Microsoft Edge as well as Firefox 50 and later. However, even though it has relatively broad support, it is still not standard and should not be used unless you have no alternative.

Methods
-------

The following methods are provided by the `HTMLInputElement` interface which represents `<input>` elements in the DOM. Also available are those methods specified by the parent interfaces, `HTMLElement`, `Element`, `Node`, and `EventTarget`.

`checkValidity()`

Returns `true` if the element's value passes validity checks; otherwise, returns `false` and fires an `invalid` event at the element.

`reportValidity()`

Returns `true` if the element's value passes validity checks; otherwise, returns `false`, fires an `invalid` event at the element, and (if the event isn't canceled) reports the problem to the user.

`select()`

Selects the entire content of the `<input>` element, if the element's content is selectable. For elements with no selectable text content (such as a visual color picker or calendar date input), this method does nothing.

`setCustomValidity()`

Sets a custom message to display if the input element's value isn't valid.

`setRangeText()`

Sets the contents of the specified range of characters in the input element to a given string. A `selectMode` parameter is available to allow controlling how the existing content is affected.

`setSelectionRange()`

Selects the specified range of characters within a textual input element. Does nothing for inputs which aren't presented as text input fields.

`showPicker()`

Displays the browser picker for the input element that would normally be displayed when the element is selected, but triggered from a button press or other user interaction.

`stepDown()`

Decrements the value of a numeric input by one, by default, or by the specified number of units.

`stepUp()`

Increments the value of a numeric input by one or by the specified number of units.

CSS
---

Inputs, being replaced elements, have a few features not applicable to non form elements. There are CSS selectors that can specifically target form controls based on their UI features, also known as UI pseudo-classes. The input element can also be targeted by type with attribute selectors. There are some properties that are especially useful as well.

### UI pseudo-classes

 Captions super relevant to the
 `<input>`
 element:
 | Pseudo-class | Description |
| --- | --- |
| `:enabled` |
 Any currently enabled element that can be activated (selected, clicked
 on, typed into, etc.) or accept focus and also has a disabled state, in
 which it can't be activated or accept focus.
  |
| `:disabled` |
 Any currently disabled element that has an enabled state, meaning it
 otherwise could be activated (selected, clicked on, typed into, etc.) or
 accept focus were it not disabled.
  |
| `:read-only` | Element not editable by the user |
| `:read-write` | Element that is editable by the user. |
| `:placeholder-shown` |
 Element that is currently displaying `placeholder` text,
 including `<input>` and `<textarea>` elements with the `placeholder` attribute present that has, as yet, no value.
  |
| `:default` |
 Form elements that are the default in a group of related elements.
 Matches checkbox and
 radio input types that
 were checked on page load or render.
  |
| `:checked` |
 Matches checkbox and
 radio input types that
 are currently checked (and the (`<option>` in a
 `<select>` that is currently selected).
  |
| `:indeterminate` | checkbox elements
 whose indeterminate property is set to true by JavaScript,
 radio elements, when all
 radio buttons with the same name value in the form are unchecked, and
 `<progress>` elements in an indeterminate state
  |
| `:valid` |
 Form controls that can have constraint validation applied and are
 currently valid.
  |
| `:invalid` |
 Form controls that have constraint validation applied and are currently
 not valid. Matches a form control whose value doesn't match the
 constraints set on it by its attributes, such as
 `required`,
 `pattern`,
 `step` and `max`.
  |
| `:in-range` |
 A non-empty input whose current value is within the range limits
 specified by the `min` and `max` attributes and the `step`.
  |
| `:out-of-range` |
 A non-empty input whose current value is NOT within the range limits
 specified by the `min`
 and `max` attributes or
 does not adhere to the `step` constraint.
  |
| `:required` | `<input>`, `<select>`, or `<textarea>` element that has the `required` attribute set on it.
 Only matches elements that can be required.
 The attribute included on a non-requirable element will not make for a match.
  |
| `:optional` | `<input>`, `<select>`, or
 `<textarea>` element that does NOT have the `required` attribute set on it.
 Does not match elements that can't be required.
  |
| `:blank` | `<input>` and `<textarea>` elements that currently have no value. |
| `:user-invalid` |
 Similar to `:invalid`, but is activated on blur. Matches
 invalid input but only after the user interaction, such as by focusing
 on the control, leaving the control, or attempting to submit the form
 containing the invalid control.
  |

#### Pseudo-classes example

We can style a checkbox label based on whether the checkbox is checked or not. In this example, we are styling the `color` and `font-weight` of the `<label>` that comes immediately after a checked input. We haven't applied any styles if the `input` is not checked.
```

<input id="checkboxInput" type="checkbox" />
<label for="checkboxInput">Toggle the checkbox on and off</label>
```

```css
input:checked + label {
  color: red;
  font-weight: bold;
}
```

### Attribute selectors

It is possible to target different types of form controls based on their `type` using attribute selectors. CSS attribute selectors match elements based on either just the presence of an attribute or the value of a given attribute.

```css
/\* matches a password input \*/
input[type="password"] {
}

/\* matches a form control whose valid values are limited to a range of values\*/
input[min][max] {
}

/\* matches a form control with a pattern attribute \*/
input[pattern] {
}
```

### ::placeholder

By default, the appearance of placeholder text is a translucent or light gray. The `::placeholder` pseudo-element is the input's `placeholder` text. It can be styled with a limited subset of CSS properties.

```css
::placeholder {
  color: blue;
}
```

Only the subset of CSS properties that apply to the `::first-line` pseudo-element can be used in a rule using `::placeholder` in its selector.

### appearance

The `appearance` property enables the displaying of (almost) any element as a platform-native style based on the operating system's theme as well as the removal of any platform-native styling with the `none` value.

You could make a `<div>` look like a radio button with `div {appearance: radio;}` or a radio look like a checkbox with `[type="radio"] {appearance: checkbox;}`, but don't.

Setting `appearance: none` removes platform native borders, but not functionality.

### caret-color

A property specific to text entry-related elements is the CSS `caret-color` property, which lets you set the color used to draw the text input caret:

#### HTML

```html
<label for="textInput">Note the red caret:</label>
<input id="textInput" class="custom" size="32" />
```

#### CSS

```css
input.custom {
  caret-color: red;
  font:
    16px "Helvetica",
    "Arial",
    "sans-serif";
}
```

#### Result

### object-position and object-fit

In certain cases (typically involving non-textual inputs and specialized interfaces), the `<input>` element is a replaced element. When it is, the position and size of the element's size and positioning within its frame can be adjusted using the CSS `object-position` and `object-fit` properties

### Styling

For more information about adding color to elements in HTML, see:

* Applying color to HTML elements using CSS.

Also see:

* Styling HTML forms
* Advanced styling for HTML forms and
* the compatibility table of CSS properties.
Additional features
-------------------

### Labels

Labels are needed to associate assistive text with an `<input>`. The `<label>` element provides explanatory information about a form field that is *always* appropriate (aside from any layout concerns you have). It's never a bad idea to use a `<label>` to explain what should be entered into an `<input>` or `<textarea>`.

#### Associated labels

The semantic pairing of `<input>` and `<label>` elements is useful for assistive technologies such as screen readers. By pairing them using the `<label>`'s `for` attribute, you bond the label to the input in a way that lets screen readers describe inputs to users more precisely.

It does not suffice to have plain text adjacent to the `<input>` element. Rather, usability and accessibility requires the inclusion of either implicit or explicit `<label>`:

```html
<!-- inaccessible -->
<p>Enter your name: <input id="name" type="text" size="30" /></p>

<!-- implicit label -->
<p>
  <label>Enter your name: <input id="name" type="text" size="30" /></label>
</p>

<!-- explicit label -->
<p>
  <label for="name">Enter your name: </label>
  <input id="name" type="text" size="30" />
</p>
```

The first example is inaccessible: no relationship exists between the prompt and the `<input>` element.

In addition to an accessible name, the label provides a larger 'hit' area for mouse and touch screen users to click on or touch. By pairing a `<label>` with an `<input>`, clicking on either one will focus the `<input>`. If you use plain text to "label" your input, this won't happen. Having the prompt part of the activation area for the input is helpful for people with motor control conditions.

As web developers, it's important that we never assume that people will know all the things that we know. The diversity of people using the web—and by extension your website—practically guarantees that some of your site's visitors will have some variation in thought processes and/or circumstances that leads them to interpret your forms very differently from you without clear and properly-presented labels.

#### Placeholders are not accessible

The `placeholder` attribute lets you specify text that appears within the `<input>` element's content area itself when it is empty. The placeholder should never be required to understand your forms. It is not a label, and should not be used as a substitute, because it isn't. The placeholder is used to provide a hint as to what an inputted value should look like, not an explanation or prompt.

Not only is the placeholder not accessible to screen readers, but once the user enters any text into the form control, or if the form control already has a value, the placeholder disappears. Browsers with automatic page translation features may skip over attributes when translating, meaning the `placeholder` may not get translated.

**Note:** Don't use the `placeholder` attribute if you can avoid it. If you need to label an `<input>` element, use the `<label>` element.

### Client-side validation

**Warning:** Client-side validation is useful, but it does *not* guarantee that the server will receive valid data. If the data must be in a specific format, *always* verify it also on the server-side, and return a `400` HTTP response if the format is invalid.

In addition to using CSS to style inputs based on the `:valid` or `:invalid` UI states based on the current state of each input, as noted in the UI pseudo-classes section above, the browser provides for client-side validation on (attempted) form submission. On form submission, if there is a form control that fails constraint validation, supporting browsers will display an error message on the first invalid form control; displaying a default message based on the error type, or a message set by you.

Some input types and other attributes place limits on what values are valid for a given input. For example, `<input type="number" min="2" max="10" step="2">` means only the number 2, 4, 6, 8, or 10 are valid. Several errors could occur, including a `rangeUnderflow` error if the value is less than 2, `rangeOverflow` if greater than 10, `stepMismatch` if the value is a number between 2 and 10, but not an even integer (does not match the requirements of the `step` attribute), or `typeMismatch` if the value is not a number.

For the input types whose domain of possible values is periodic (that is, at the highest possible value, the values wrap back around to the beginning rather than ending), it's possible for the values of the `max` and `min` properties to be reversed, which indicates that the range of permitted values starts at `min`, wraps around to the lowest possible value, then continues on until `max` is reached. This is particularly useful for dates and times, such as when you want to allow the range to be from 8 PM to 8 AM:

```html
<input type="time" min="20:00" max="08:00" name="overnight" />
```

Specific attributes and their values can lead to a specific error `ValidityState`:

 Validity object errors depend on the `<input>`
 attributes and their values:
 | Attribute | Relevant property | Description |
| --- | --- | --- |
| `max` | `validityState.rangeOverflow` |
 Occurs when the value is greater than the maximum value as defined by
 the `max` attribute
  |
| `maxlength` | `validityState.tooLong` | Occurs when the number of characters is greater than the number allowed by the `maxlength` property |
| `min` | `validityState.rangeUnderflow` | Occurs when the value is less than the minimum value as defined by the `min` attribute |
| `minlength` | `validityState.tooShort` | Occurs when the number of characters is less than the number required by the `minlength` property |
| `pattern` | `validityState.patternMismatch` | Occurs when a pattern attribute is included with a valid regular expression and the `value` does not match it. |
| `required` | `validityState.valueMissing` | Occurs when the `required` attribute is present but the value is `null` or radio or checkbox is not checked. |
| `step` | `validityState.stepMismatch` |
 The value doesn't match the step increment. Increment default is `1`, so only integers are valid on `type="number"`
 is step is not included. `step="any"` will never throw this error.
  |
| `type` | `validityState.typeMismatch` | Occurs when the value is not of the correct type, for example an email does not contain an `@` or a url doesn't contain a protocol. |

If a form control doesn't have the `required` attribute, no value, or an empty string, is not invalid. Even if the above attributes are present, with the exception of `required`, an empty string will not lead to an error.

We can set limits on what values we accept, and supporting browsers will natively validate these form values and alert the user if there is a mistake when the form is submitted.

In addition to the errors described in the table above, the `validityState` interface contains the `badInput`, `valid`, and `customError` boolean readonly properties. The validity object includes:

* `validityState.valueMissing`
* `validityState.typeMismatch`
* `validityState.patternMismatch`
* `validityState.tooLong`
* `validityState.tooShort`
* `validityState.rangeUnderflow`
* `validityState.rangeOverflow`
* `validityState.stepMismatch`
* `validityState.badInput`
* `validityState.valid`
* `validityState.customError`

For each of these Boolean properties, a value of `true` indicates that the specified reason validation may have failed is true, with the exception of the `valid` property, which is `true` if the element's value obeys all constraints.

If there is an error, supporting browsers will both alert the user and prevent the form from being submitted. A word of caution: if a custom error is set to a truthy value (anything other than the empty string or `null`), the form will be prevented from being submitted. If there is no custom error message, and none of the other properties return true, `valid` will be true, and the form can be submitted.

```js
function validate(input) {
  let validityState_object = input.validity;
  if (validityState_object.valueMissing) {
    input.setCustomValidity("A value is required");
  } else if (validityState_object.rangeUnderflow) {
    input.setCustomValidity("Your value is too low");
  } else if (validityState_object.rangeOverflow) {
    input.setCustomValidity("Your value is too high");
  } else {
    input.setCustomValidity("");
  }
}
```

The last line, setting the custom validity message to the empty string is vital. If the user makes an error, and the validity is set, it will fail to submit, even if all the values are valid, until the message is `null`.

#### Custom validation error example

If you want to present a custom error message when a field fails to validate, you need to use the Constraint Validation API available on `<input>` (and related) elements. Take the following form:

```html
<form>
  <label for="name">Enter username (upper and lowercase letters): </label>
  <input type="text" name="name" id="name" required pattern="[A-Za-z]+" />
  <button>Submit</button>
</form>
```

The basic HTML form validation features will cause this to produce a default error message if you try to submit the form with either no valid filled in, or a value that does not match the `pattern`.

If you wanted to instead display custom error messages, you could use JavaScript like the following:

```js
const nameInput = document.querySelector("input");

nameInput.addEventListener("input", () => {
  nameInput.setCustomValidity("");
  nameInput.checkValidity();
});

nameInput.addEventListener("invalid", () => {
  if (nameInput.value === "") {
    nameInput.setCustomValidity("Enter your username!");
  } else {
    nameInput.setCustomValidity(
      "Usernames can only contain upper and lowercase letters. Try again!",
    );
  }
});
```

The example renders like so:

In brief:

* We check the valid state of the input element every time its value is changed by running the `checkValidity()` method via the `input` event handler.
* If the value is invalid, an `invalid` event is raised, and the `invalid` event handler function is run. Inside this function we work out whether the value is invalid because it is empty, or because it doesn't match the pattern, using an `if ()` block, and set a custom validity error message.
* As a result, if the input value is invalid when the submit button is pressed, one of the custom error messages will be shown.
* If it is valid, it will submit as you'd expect. For this to happen, the custom validity has to be cancelled, by invoking `setCustomValidity()` with an empty string value. We therefore do this every time the `input` event is raised. If you don't do this, and a custom validity was previously set, the input will register as invalid, even if it currently contains a valid value on submission.

**Note:** Always validate input constraints both client side and server side. Constraint validation doesn't remove the need for validation on the *server side*. Invalid values can still be sent by older browsers or by bad actors.

**Note:** Firefox supported a proprietary error attribute — `x-moz-errormessage` — for many versions, which allowed you set custom error messages in a similar way. This has been removed as of version 66 (see Firefox bug 1513890).

### Localization

The allowed inputs for certain `<input>` types depend on the locale. In some locales, 1,000.00 is a valid number, while in other locales the valid way to enter this number is 1.000,00.

Firefox uses the following heuristics to determine the locale to validate the user's input (at least for `type="number"`):

* Try the language specified by a `lang`/`xml:lang` attribute on the element or any of its parents.
* Try the language specified by any `Content-Language` HTTP header. Or,
* If none specified, use the browser's locale.
### Technical summary

|  |  |
| --- | --- |
| Content categories | Flow content, listed, submittable, resettable, form-associated element,
 phrasing content. If the `type` is not
 `hidden`, then labelable element, palpable content.
  |
| Permitted content | None; it is a void element. |
| Tag omission | Must have a start tag and must not have an end tag. |
| Permitted parents |
 Any element that accepts
 phrasing content.
  |
| Implicit ARIA role | * `type=button`:
 `button`
* `type=checkbox`:
 `checkbox`
* `type=email`
    + with no `list` attribute:
     `textbox`
    + with `list` attribute: `combobox`
* `type=image`:
 `button`
* `type=number`: `spinbutton`
* `type=radio`: `radio`
* `type=range`: `slider`
* `type=reset`:
 `button`
* `type=search`
    + with no `list` attribute: `searchbox`
    + with `list` attribute:`combobox`
* `type=submit`:
 `button`
* `type=tel`
    + with no `list` attribute:
     `textbox`
    + with `list` attribute: `combobox`
* `type=text`
    + with no `list` attribute:
     `textbox`
    + with `list` attribute: `combobox`
* `type=url`
    + with no `list` attribute:
     `textbox`
    + with `list` attribute: `combobox`
* `type=color|date|datetime-local|file|hidden|month|password|time|week`:
 no corresponding role
 |
| Permitted ARIA roles | * `type=button`: `checkbox`,
 `combobox`,
 `link`,
 `menuitem`,
 `menuitemcheckbox`,
 `menuitemradio`,
 `option`, `radio`,
 `switch`, `tab`
* `type=checkbox`: `button` when used
 with `aria-pressed`,
 `menuitemcheckbox`,
 `option`, `switch`
* `type=image`: `link`,
 `menuitem`,
 `menuitemcheckbox`,
 `menuitemradio`,
 `radio`, `switch`
* `type=radio`: `menuitemradio`
* `type=text` with no `list` attribute:
 `combobox`, `searchbox`,
 `spinbutton`
* `type=color|date|datetime-local|email|file|hidden|`
`month|number|password|range|reset|search|submit|tel|url|week`
 or `text` with `list` attribute: no
 `role` permitted
 |
| DOM interface | `HTMLInputElement` |

Accessibility concerns
----------------------

### Labels

When including inputs, it is an accessibility requirement to add labels alongside. This is needed so those who use assistive technologies can tell what the input is for. Also, clicking or touching a label gives focus to the label's associated form control. This improves the accessibility and usability for sighted users, increases the area a user can click or touch to activate the form control. This is especially useful (and even needed) for radio buttons and checkboxes, which are tiny. For more information about labels in general see Labels .

The following is an example of how to associate the `<label>` with an `<input>` element in the above style. You need to give the `<input>` an `id` attribute. The `<label>` then needs a `for` attribute whose value is the same as the input's `id`.

```html
<label for="peas">Do you like peas?</label>
<input type="checkbox" name="peas" id="peas" />
```

### Size

Interactive elements such as form input should provide an area large enough that it is easy to activate them. This helps a variety of people, including people with motor control issues and people using non-precise forms of input such as a stylus or fingers. A minimum interactive size of 44×44 CSS pixels is recommended.

* Understanding Success Criterion 2.5.5: Target Size | W3C Understanding WCAG 2.1
* Target Size and 2.5.5 | Adrian Roselli
* Quick test: Large touch targets - The A11Y Project
Specifications
--------------

| Specification |
| --- |
| HTML Standard # the-input-element |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

See also
--------

* Form constraint validation
* Your first HTML form
* How to structure an HTML form
* The native form widgets
* Sending form data
* Form data validation
* How to build custom form widgets
* HTML forms in legacy browsers
* Styling HTML forms
* Advanced styling for HTML forms
* CSS property compatibility table


<font> - HTML: HyperText Markup Language

<font>
======

**Deprecated:** This feature is no longer recommended. Though some browsers might still support it, it may have already been removed from the relevant web standards, may be in the process of being dropped, or may only be kept for compatibility purposes. Avoid using it, and update existing code if possible; see the compatibility table at the bottom of this page to guide your decision. Be aware that this feature may cease to work at any time.

The **`<font>`** HTML element defines the font size, color and face for its content.

**Warning:** Do not use this element. Use the CSS Fonts properties to style text.

Attributes
----------

Like all other HTML elements, this element supports the global attributes.

`color`
Deprecated

This attribute sets the text color using either a named color or a color specified in the hexadecimal #RRGGBB format.

`face`
Deprecated

This attribute contains a comma-separated list of one or more font names. The document text in the default style is rendered in the first font face that the client's browser supports. If no font listed is installed on the local system, the browser typically defaults to the proportional or fixed-width font for that system.

`size`
Deprecated

This attribute specifies the font size as either a numeric or relative value. Numeric values range from `1` to `7` with `1` being the smallest and `3` the default. It can be defined using a relative value, like `+2` or `-3`, which sets it relative to `3`, the default value.

DOM interface
-------------

This element implements the `HTMLFontElement` interface.

Specifications
--------------

| Specification |
| --- |
| HTML Standard # font |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.


<article>: The Article Contents element - HTML: HyperText Markup Language

<article>: The Article Contents element
=======================================

The **`<article>`** HTML element represents a self-contained composition in a document, page, application, or site, which is intended to be independently distributable or reusable (e.g., in syndication). Examples include: a forum post, a magazine or newspaper article, or a blog entry, a product card, a user-submitted comment, an interactive widget or gadget, or any other independent item of content.

Try it
------

A given document can have multiple articles in it; for example, on a blog that shows the text of each article one after another as the reader scrolls, each post would be contained in an `<article>` element, possibly with one or more `<section>`s within.

|  |  |
| --- | --- |
| Content categories | Flow content,
 sectioning content,
 palpable content |
| Permitted content | Flow content. |
| Tag omission | None, both the starting and ending tag are mandatory. |
| Permitted parents |
 Any element that accepts
 flow content. Note that an `<article>` element must not be a
 descendant of an `<address>` element.
  |
| Implicit ARIA role | `article` |
| Permitted ARIA roles | `application`, `document`,
 `feed`, `main`,
 `none`, `presentation`,
 `region` |
| DOM interface | `HTMLElement` |

Attributes
----------

This element only includes the global attributes.

Usage notes
-----------

* Each `<article>` should be identified, typically by including a heading (`<h1>` - `<h6>` element) as a child of the `<article>` element.
* When an `<article>` element is nested, the inner element represents an article related to the outer element. For example, the comments of a blog post can be `<article>` elements nested in the `<article>` representing the blog post.
* Author information of an `<article>` element can be provided through the `<address>` element, but it doesn't apply to nested `<article>` elements.
* The publication date and time of an `<article>` element can be described using the `datetime` attribute of a `<time>` element.
Examples
--------

```html
<article class="film\_review">
  <h2>Jurassic Park</h2>
  <section class="main\_review">
    <h3>Review</h3>
    <p>Dinos were great!</p>
  </section>
  <section class="user\_reviews">
    <h3>User reviews</h3>
    <article class="user\_review">
      <h4>Too scary!</h4>
      <p>Way too scary for me.</p>
      <footer>
        <p>
          Posted on
          <time datetime="2015-05-16 19:00">May 16</time>
          by Lisa.
        </p>
      </footer>
    </article>
    <article class="user\_review">
      <h4>Love the dinos!</h4>
      <p>I agree, dinos are my favorite.</p>
      <footer>
        <p>
          Posted on
          <time datetime="2015-05-17 19:00">May 17</time>
          by Tom.
        </p>
      </footer>
    </article>
  </section>
  <footer>
    <p>
      Posted on
      <time datetime="2015-05-15 19:00">May 15</time>
      by Staff.
    </p>
  </footer>
</article>
```

Result
------

Specifications
--------------

| Specification |
| --- |
| HTML Standard # the-article-element |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

See also
--------

* Other section-related elements: `<body>`, `<nav>`, `<section>`, `<aside>`, h1, h2, h3, h4, h5, h6, `<hgroup>`, `<header>`, `<footer>`, `<address>`
* Using HTML sections and outlines


<ins>: The Inserted Text element - HTML: HyperText Markup Language

<ins>: The Inserted Text element
================================

The **`<ins>`** HTML element represents a range of text that has been added to a document. You can use the `<del>` element to similarly represent a range of text that has been deleted from the document.

Try it
------

|  |  |
| --- | --- |
| Content categories | Phrasing content,
 flow content.
  |
| Permitted content | Transparent. |
| Tag omission | None, both the starting and ending tag are mandatory. |
| Permitted parents |
 Any element that accepts
 phrasing content.
  |
| Implicit ARIA role | `insertion` |
| Permitted ARIA roles | Any |
| DOM interface | `HTMLModElement` |

Attributes
----------

This element includes the global attributes.

`cite`

This attribute defines the URI of a resource that explains the change, such as a link to meeting minutes or a ticket in a troubleshooting system.

`datetime`

This attribute indicates the time and date of the change and must be a valid date with an optional time string. If the value cannot be parsed as a date with an optional time string, the element does not have an associated timestamp. For the format of the string without a time, see Format of a valid date string. The format of the string if it includes both date and time is covered in Format of a valid local date and time string.

Examples
--------

```html
<ins>This text has been inserted</ins>
```

### Result

Accessibility concerns
----------------------

The presence of the `<ins>` element is not announced by most screen reading technology in its default configuration. It can be made to be announced by using the CSS `content` property, along with the `::before` and `::after` pseudo-elements.

```css
ins::before,
ins::after {
  clip-path: inset(100%);
  clip: rect(1px, 1px, 1px, 1px);
  height: 1px;
  overflow: hidden;
  position: absolute;
  white-space: nowrap;
  width: 1px;
}

ins::before {
  content: " [insertion start] ";
}

ins::after {
  content: " [insertion end] ";
}
```

Some people who use screen readers deliberately disable announcing content that creates extra verbosity. Because of this, it is important to not abuse this technique and only apply it in situations where not knowing content has been inserted would adversely affect understanding.

* Short note on making your mark (more accessible) | The Paciello Group
* Tweaking Text Level Styles | Adrian Roselli
Specifications
--------------

| Specification |
| --- |
| HTML Standard # the-ins-element |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

See also
--------

* `<del>` element for marking deletion into a document


<mark>: The Mark Text element - HTML: HyperText Markup Language

<mark>: The Mark Text element
=============================

The **`<mark>`** HTML element represents text which is **marked** or **highlighted** for reference or notation purposes due to the marked passage's relevance in the enclosing context.

Try it
------

Attributes
----------

This element only includes the global attributes.

Usage notes
-----------

Typical use cases for `<mark>` include:

* When used in a quotation (`<q>`) or block quote (`<blockquote>`), it generally indicates text which is of special interest but is not marked in the original source material, or material which needs special scrutiny even though the original author didn't think it was of particular importance. Think of this like using a highlighter pen in a book to mark passages that you find of interest.
* Otherwise, `<mark>` indicates a portion of the document's content which is likely to be relevant to the user's current activity. This might be used, for example, to indicate the words that matched a search operation.
* Don't use `<mark>` for syntax highlighting purposes; instead, use the `<span>` element with appropriate CSS applied to it.

**Note:** Don't confuse `<mark>` with the `<strong>` element; `<mark>` is used to denote content which has a degree of *relevance*, while `<strong>` indicates spans of text of *importance*.

Examples
--------

### Marking text of interest

In this first example, a `<mark>` element is used to mark some text within a quote which is of particular interest to the user.

```html
<blockquote>
  It is a period of civil war. Rebel spaceships, striking from a hidden base,
  have won their first victory against the evil Galactic Empire. During the
  battle, <mark>Rebel spies managed to steal secret plans</mark> to the Empire's
  ultimate weapon, the DEATH STAR, an armored space station with enough power to
  destroy an entire planet.
</blockquote>
```

#### Result

### Identifying context-sensitive passages

This example demonstrates using `<mark>` to mark search results within a passage.

```html
<p>
  It is a dark time for the Rebellion. Although the Death Star has been
  destroyed, <mark class="match">Imperial</mark> troops have driven the Rebel
  forces from their hidden base and pursued them across the galaxy.
</p>

<p>
  Evading the dreaded <mark class="match">Imperial</mark> Starfleet, a group of
  freedom fighters led by Luke Skywalker has established a new secret base on
  the remote ice world of Hoth.
</p>
```

To help distinguish the use of `<mark>` for search results from other potential usage, this example applies the custom class `"match"` to each match.

#### Result

Accessibility concerns
----------------------

The presence of the `mark` element is not announced by most screen reading technology in its default configuration. It can be made to be announced by using the CSS `content` property, along with the `::before` and `::after` pseudo-elements.

```css
mark::before,
mark::after {
  clip-path: inset(100%);
  clip: rect(1px, 1px, 1px, 1px);
  height: 1px;
  overflow: hidden;
  position: absolute;
  white-space: nowrap;
  width: 1px;
}

mark::before {
  content: " [highlight start] ";
}

mark::after {
  content: " [highlight end] ";
}
```

Some people who use screen readers deliberately disable announcing content that creates extra verbosity. Because of this, it is important to not abuse this technique and only apply it in situations where not knowing content has been highlighted would adversely affect understanding.

* Short note on making your mark (more accessible) | The Paciello Group
* Tweaking Text Level Styles | Adrian Roselli
Technical summary
-----------------

|  |  |
| --- | --- |
| Content categories | Flow content,
 phrasing content, palpable content.
  |
| Permitted content | Phrasing content. |
| Tag omission | None, both the starting and ending tag are mandatory. |
| Permitted parents |
 Any element that accepts
 phrasing content.
  |
| Implicit ARIA role | No corresponding role |
| Permitted ARIA roles | Any |
| DOM interface | `HTMLElement` |

Specifications
--------------

| Specification |
| --- |
| HTML Standard # the-mark-element |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.


<br>: The Line Break element - HTML: HyperText Markup Language

<br>: The Line Break element
============================

The **`<br>`** HTML element produces a line break in text (carriage-return). It is useful for writing a poem or an address, where the division of lines is significant.

Try it
------

As you can see from the above example, a `<br>` element is included at each point where we want the text to break. The text after the `<br>` begins again at the start of the next line of the text block.

**Note:** Do not use `<br>` to create margins between paragraphs; wrap them in `<p>` elements and use the CSS `margin` property to control their size.

Attributes
----------

This element's attributes include the global attributes.

### Deprecated attributes

`clear`
Deprecated

Indicates where to begin the next line after the break.

Styling with CSS
----------------

The `<br>` element has a single, well-defined purpose — to create a line break in a block of text. As such, it has no dimensions or visual output of its own, and there is very little you can do to style it.

You can set a `margin` on `<br>` elements themselves to increase the spacing between the lines of text in the block, but this is a bad practice — you should use the `line-height` property that was designed for that purpose.

Examples
--------

### Simple br

In the following example we use `<br>` elements to create line breaks between the different lines of a postal address:

```html
Mozilla<br />
331 E. Evelyn Avenue<br />
Mountain View, CA<br />
94041<br />
USA<br />
```

#### Result

Accessibility concerns
----------------------

Creating separate paragraphs of text using `<br>` is not only bad practice, it is problematic for people who navigate with the aid of screen reading technology. Screen readers may announce the presence of the element, but not any content contained within `<br>`s. This can be a confusing and frustrating experience for the person using the screen reader.

Use `<p>` elements, and use CSS properties like `margin` to control their spacing.

Technical summary
-----------------

|  |  |
| --- | --- |
| Content categories | Flow content,
 phrasing content.
  |
| Permitted content | None; it is a void element. |
| Tag omission |
 Must have a start tag, and must not have an end tag. In XHTML documents,
 write this element as `<br />`.
  |
| Permitted parents |
 Any element that accepts
 phrasing content.
  |
| Implicit ARIA role | No corresponding role |
| Permitted ARIA roles | `none`, `presentation` |
| DOM interface | `HTMLBRElement` |

Specifications
--------------

| Specification |
| --- |
| HTML Standard # the-br-element |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

See also
--------

* `<address>` element
* `<p>` element
* `<wbr>` element


<main>: The Main element - HTML: HyperText Markup Language

<main>: The Main element
========================

The **`<main>`** HTML element represents the dominant content of the `<body>` of a document. The main content area consists of content that is directly related to or expands upon the central topic of a document, or the central functionality of an application.

Try it
------

A document mustn't have more than one `<main>` element that doesn't have the `hidden` attribute specified.

|  |  |
| --- | --- |
| Content categories | Flow content, palpable content. |
| Permitted content | Flow content. |
| Tag omission | None; both the starting and ending tags are mandatory. |
| Permitted parents |
 Where
 flow content
 is expected, but only if it is a
 hierarchically correct `main` element.
  |
| Implicit ARIA role | `main` |
| Permitted ARIA roles | No `role` permitted |
| DOM interface | `HTMLElement` |

Attributes
----------

This element only includes the global attributes.

Usage notes
-----------

The content of a `<main>` element should be unique to the document. Content that is repeated across a set of documents or document sections such as sidebars, navigation links, copyright information, site logos, and search forms shouldn't be included unless the search form is the main function of the page.

`<main>` doesn't contribute to the document's outline; that is, unlike elements such as `<body>`, headings such as h2, and such, `<main>` doesn't affect the DOM's concept of the structure of the page. It's strictly informative.

Examples
--------

```html
<!-- other content -->

<main>
  <h1>Apples</h1>
  <p>The apple is the pomaceous fruit of the apple tree.</p>

  <article>
    <h2>Red Delicious</h2>
    <p>
      These bright red apples are the most common found in many supermarkets.
    </p>
    <p>…</p>
    <p>…</p>
  </article>

  <article>
    <h2>Granny Smith</h2>
    <p>These juicy, green apples make a great filling for apple pies.</p>
    <p>…</p>
    <p>…</p>
  </article>
</main>

<!-- other content -->
```

### Result

Accessibility concerns
----------------------

### Landmark

The `<main>` element behaves like a `main` landmark role. Landmarks can be used by assistive technology to quickly identify and navigate to large sections of the document. Prefer using the `<main>` element over declaring `role="main"`, unless there are legacy browser support concerns.

### Skip navigation

Skip navigation, also known as "skipnav", is a technique that allows an assistive technology user to quickly bypass large sections of repeated content (main navigation, info banners, etc.). This lets the user access the main content of the page faster.

Adding an `id` attribute to the `<main>` element lets it be a target of a skip navigation link.

```html
<body>
  <a href="#main-content">Skip to main content</a>

  <!-- navigation and header content -->

  <main id="main-content">
    <!-- main page content -->
  </main>
</body>
```

* WebAIM: "Skip Navigation" Links
### Reader mode

Browser reader mode functionality looks for the presence of the `<main>` element, as well as heading and content sectioning elements when converting content into a specialized reader view.

* Building websites for Safari Reader Mode and other reading apps.
Specifications
--------------

| Specification |
| --- |
| HTML Standard # the-main-element |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

See also
--------

* Basic structural elements: `<html>`, `<head>`, `<body>`
* Section-related elements: `<article>`, `<aside>`, `<footer>`, `<header>`, or `<nav>`
* ARIA: Main role


<image>: The Image element - HTML: HyperText Markup Language

<image>: The Image element
==========================

**Deprecated:** This feature is no longer recommended. Though some browsers might still support it, it may have already been removed from the relevant web standards, may be in the process of being dropped, or may only be kept for compatibility purposes. Avoid using it, and update existing code if possible; see the compatibility table at the bottom of this page to guide your decision. Be aware that this feature may cease to work at any time.

**Non-standard:** This feature is non-standard and is not on a standards track. Do not use it on production sites facing the Web: it will not work for every user. There may also be large incompatibilities between implementations and the behavior may change in the future.

 The **`<image>`** HTML element is an ancient and poorly supported precursor to the `<img>` element.
 **It should not be used**.

Some browsers will attempt to automatically convert this into an `<img>` element, and may succeed if the `src` attribute is specified as well.

Specifications
--------------

 This does not appear to have been part of any formal specification.
 It was mentioned in HTML+ Discussion Document - Dave Raggett, November 8, 1993 (Section 5.9 - Images), but was not part of the first revision of HyperText Markup Language Specification - 2.0 in 1994.

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

See also
--------

* `<img>`: The correct way to display an image in a document
* `<picture>`: A more powerful correct way to display an image in a document


<footer>: The Footer element - HTML: HyperText Markup Language

<footer>: The Footer element
============================

The **`<footer>`** HTML element represents a footer for its nearest ancestor sectioning content or sectioning root element. A `<footer>` typically contains information about the author of the section, copyright data or links to related documents.

Try it
------

|  |  |
| --- | --- |
| Content categories | Flow content, palpable content. |
| Permitted content | Flow content, but with no `<footer>` or
 `<header>` descendants.
  |
| Tag omission | None, both the starting and ending tag are mandatory. |
| Permitted parents |
 Any element that accepts
 flow content. Note that a `<footer>` element must not be a
 descendant of an `<address>`,
 `<header>` or another
 `<footer>` element.
  |
| Implicit ARIA role | contentinfo, or
 generic
 if a descendant of an
 article,
 aside,
 main,
 nav or
 section element, or
 an element with
 `role=article`,
 complementary,
 main,
 navigation
 or
 region |
| Permitted ARIA roles | `group`, `presentation` or
 `none` |
| DOM interface | `HTMLElement` |

Attributes
----------

This element only includes the global attributes.

Usage notes
-----------

* Enclose information about the author in an `<address>` element that can be included into the `<footer>` element.
* When the nearest ancestor sectioning content or sectioning root element is the body element the footer applies to the whole page.
* The `<footer>` element is not sectioning content and therefore doesn't introduce a new section in the outline.
Examples
--------

```html
<body>
  <h3>FIFA World Cup top goalscorers</h3>
  <ol>
    <li>Miroslav Klose, 16</li>
    <li>Ronaldo Nazário, 15</li>
    <li>Gerd Müller, 14</li>
  </ol>

  <footer>
    <small>
      Copyright © 2023 Football History Archives. All Rights Reserved.
    </small>
  </footer>
</body>
```

```css
footer {
  text-align: center;
  padding: 5px;
  background-color: #abbaba;
  color: #000;
}
```

Accessibility concerns
----------------------

Prior to the release of Safari 13, the `contentinfo` landmark role was not properly exposed by VoiceOver. If needing to support legacy Safari browsers, add `role="contentinfo"` to the `footer` element to ensure the landmark will be properly exposed.

* Related: WebKit Bugzilla: 146930 – AX: HTML native elements (header, footer, main, aside, nav) should work the same as ARIA landmarks, sometimes they don't
Specifications
--------------

| Specification |
| --- |
| HTML Standard # the-footer-element |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

See also
--------

* Other section-related elements: `<body>`, `<nav>`, `<article>`, `<aside>`, h1, h2, h3, h4, h5, h6, `<hgroup>`, `<header>`, `<section>`, `<address>`;
* Using HTML sections and outlines
* ARIA: Contentinfo role


<h1>–<h6>: The HTML Section Heading elements - HTML: HyperText Markup Language

<h1>–<h6>: The HTML Section Heading elements
============================================

The **`<h1>`** to **`<h6>`** HTML elements represent six levels of section headings. `<h1>` is the highest section level and `<h6>` is the lowest. By default, all heading elements create a block-level box in the layout, starting on a new line and taking up the full width available in their containing block.

Try it
------

|  |  |
| --- | --- |
| Content categories | Flow content, heading content, palpable content. |
| Permitted content | Phrasing content. |
| Tag omission | None, both the starting and ending tag are mandatory. |
| Permitted parents |
 Any element that accepts
 flow content.
  |
| Implicit ARIA role | heading |
| Permitted ARIA roles | `tab`, `presentation` or
 `none` |
| DOM interface | `HTMLHeadingElement` |

Attributes
----------

These elements only include the global attributes.

Usage notes
-----------

* Heading information can be used by user agents to construct a table of contents for a document automatically.
* Do not use heading elements to resize text. Instead, use the CSS `font-size` property.
* Do not skip heading levels: always start from `<h1>`, followed by `<h2>` and so on.
### Avoid using multiple `<h1>` elements on one page

While using multiple `<h1>` elements on one page is allowed by the HTML standard (as long as they are not nested), this is not considered a best practice. A page should generally have a single `<h1>` element that describes the content of the page (similar to the document's `<title> element`).

**Note:** Nesting multiple `<h1>` elements in nested sectioning elements was allowed in older versions of the HTML standard. However, this was never considered a best practice and is now non-conforming. Read more in There Is No Document Outline Algorithm.

Prefer using only one `<h1>` per page and nest headings without skipping levels.

Examples
--------

### All headings

The following code shows all the heading levels, in use.

```html
<h1>Heading level 1</h1>
<h2>Heading level 2</h2>
<h3>Heading level 3</h3>
<h4>Heading level 4</h4>
<h5>Heading level 5</h5>
<h6>Heading level 6</h6>
```

### Example page

The following code shows a few headings with some content under them.

```html
<h1>Heading elements</h1>
<h2>Summary</h2>
<p>Some text here…</p>

<h2>Examples</h2>
<h3>Example 1</h3>
<p>Some text here…</p>

<h3>Example 2</h3>
<p>Some text here…</p>

<h2>See also</h2>
<p>Some text here…</p>
```

Accessibility concerns
----------------------

### Navigation

A common navigation technique for users of screen reading software is to quickly jump from heading to heading in order to determine the content of the page. Because of this, it is important to not skip one or more heading levels. Doing so may create confusion, as the person navigating this way may be left wondering where the missing heading is.

**Don't do this:**

```html
<h1>Heading level 1</h1>
<h3>Heading level 3</h3>
<h4>Heading level 4</h4>
```

**Prefer this:**

```html
<h1>Heading level 1</h1>
<h2>Heading level 2</h2>
<h3>Heading level 3</h3>
```

#### Nesting

Headings may be nested as subsections to reflect the organization of the content of the page. Most screen readers can also generate an ordered list of all the headings on a page, which can help a person quickly determine the hierarchy of the content:

1. `h1` Beetles
    1. `h2` Etymology
    2. `h2` Distribution and Diversity
    3. `h2` Evolution
        1. `h3` Late Paleozoic
        2. `h3` Jurassic
        3. `h3` Cretaceous
        4. `h3` Cenozoic
    4. `h2` External Morphology
        1. `h3` Head
            1. `h4` Mouthparts
        2. `h3` Thorax
            1. `h4` Prothorax
            2. `h4` Pterothorax
        3. `h3` Legs
        4. `h3` Wings
        5. `h3` Abdomen

When headings are nested, heading levels may be "skipped" when closing a subsection.

* Headings • Page Structure • WAI Web Accessibility Tutorials
* MDN Understanding WCAG, Guideline 1.3 explanations
* Understanding Success Criterion 1.3.1 | W3C Understanding WCAG 2.0
* MDN Understanding WCAG, Guideline 2.4 explanations
* Understanding Success Criterion 2.4.1 | W3C Understanding WCAG 2.0
* Understanding Success Criterion 2.4.6 | W3C Understanding WCAG 2.0
* Understanding Success Criterion 2.4.10 | W3C Understanding WCAG 2.0
### Labeling section content

Another common navigation technique for users of screen reading software is to generate a list of sectioning content and use it to determine the page's layout.

Sectioning content can be labeled using a combination of the `aria-labelledby` and `id` attributes, with the label concisely describing the purpose of the section. This technique is useful for situations where there is more than one sectioning element on the same page.

#### Sectioning content examples

```html
<header>
  <nav aria-labelledby="primary-navigation">
    <h2 id="primary-navigation">Primary navigation</h2>
    <!-- navigation items -->
  </nav>
</header>

<!-- page content -->

<footer>
  <nav aria-labelledby="footer-navigation">
    <h2 id="footer-navigation">Footer navigation</h2>
    <!-- navigation items -->
  </nav>
</footer>
```

In this example, screen reading technology would announce that there are two `<nav>` sections, one called "Primary navigation" and one called "Footer navigation". If labels were not provided, the person using screen reading software may have to investigate each `nav` element's contents to determine their purpose.

* Using the aria-labelledby attribute
* Labeling Regions • Page Structure • W3C WAI Web Accessibility Tutorials
Specifications
--------------

| Specification |
| --- |
| HTML Standard # the-h1,-h2,-h3,-h4,-h5,-and-h6-elements |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

See also
--------

* `<p>`
* `<div>`
* `<section>`


<tfoot>: The Table Foot element - HTML: HyperText Markup Language

<tfoot>: The Table Foot element
===============================

The **`<tfoot>`** HTML element defines a set of rows summarizing the columns of the table.

Try it
------

Attributes
----------

This element includes the global attributes.

### Deprecated attributes

The following attributes are deprecated and should not be used. They are documented below for reference when updating existing code and for historical interest only.

`align`
Deprecated

This enumerated attribute specifies how horizontal alignment of each cell content will be handled. Possible values are:

* `left`, aligning the content to the left of the cell
* `center`, centering the content in the cell
* `right`, aligning the content to the right of the cell
* `justify`, inserting spaces into the textual content so that the content is justified in the cell
* `char`, aligning the textual content on a special character with a minimal offset, defined by the `char` and `charoff` attributes.

If this attribute is not set, the `left` value is assumed.

**Note:**

* To achieve the same effect as the `left`, `center`, `right` or `justify` values, use the CSS `text-align` property on it.
* To achieve the same effect as the `char` value, in CSS, you can use the value of the `char` as the value of the `text-align` property.

`bgcolor`
Deprecated

The background color of the table. It is a 6-digit hexadecimal RGB code, prefixed by a '`#`'. One of the predefined color keywords can also be used.

To achieve a similar effect, use the CSS `background-color` property.

`char`
Deprecated

This attribute specifies the alignment of the content in a column to a character. Typical values for this include a period (.) when attempting to align numbers or monetary values. If `align` is not set to `char`, this attribute is ignored.

`charoff`
Deprecated

This attribute is used to indicate the number of characters to offset the column data from the alignment characters specified by the `char` attribute.

`valign`
Deprecated

This attribute specifies the vertical alignment of the text within each row of cells of the table footer. Possible values for this attribute are:

* `baseline`, which will put the text as close to the bottom of the cell as it is possible, but align it on the baseline of the characters instead of the bottom of them. If characters are all of the size, this has the same effect as `bottom`.
* `bottom`, which will put the text as close to the bottom of the cell as it is possible;
* `middle`, which will center the text in the cell;
* and `top`, which will put the text as close to the top of the cell as it is possible.

**Note:** Do not use this attribute as it is obsolete (and not supported) in the latest standard: instead set the CSS `vertical-align` property on it.

Examples
--------

Please see the `<table>` page for examples on `<tfoot>`.

Technical summary
-----------------

|  |  |
| --- | --- |
| Content categories | None. |
| Permitted content | Zero or more `<tr>` elements. |
| Tag omission |
 The start tag is mandatory. The end tag may be omitted if there is no
 more content in the parent `<table>` element.
  |
| Permitted parents |
 A `<table>` element. The
 `<tfoot>` must appear after any
 `<caption>`,
 `<colgroup>`, `<thead>`,
 `<tbody>`, or `<tr>`
 element. Note that this is the requirement in HTML.Originally, in HTML4, the opposite was true: the `<tfoot>` element could not be placed after any
 `<tbody>` or `<tr>`
 element.
  |
| Implicit ARIA role | `rowgroup` |
| Permitted ARIA roles | Any |
| DOM interface | `HTMLTableSectionElement` |

Specifications
--------------

| Specification |
| --- |
| HTML Standard # the-tfoot-element |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

See also
--------

* Other table-related HTML Elements: `<caption>`, `<col>`, `<colgroup>`, `<table>`, `<tbody>`, `<td>`, `<th>`, `<thead>`, `<tr>`;
* CSS properties and pseudo-classes that may be specially useful to style the `<tfoot>` element:
    + the `:nth-child` pseudo-class to set the alignment on the cells of the column;
    + the `text-align` property to align all cells content on the same character, like '.'.


<aside>: The Aside element - HTML: HyperText Markup Language

<aside>: The Aside element
==========================

The **`<aside>`** HTML element represents a portion of a document whose content is only indirectly related to the document's main content. Asides are frequently presented as sidebars or call-out boxes.

Try it
------

Attributes
----------

This element only includes the global attributes.

Usage notes
-----------

* Do not use the `<aside>` element to tag parenthesized text, as this kind of text is considered part of the main flow.
Examples
--------

### Using <aside>

This example uses `<aside>` to mark up a paragraph in an article. The paragraph is only indirectly related to the main article content:

```html
<article>
  <p>
    The Disney movie <cite>The Little Mermaid</cite> was first released to
    theatres in 1989.
  </p>
  <aside>
    <p>The movie earned $87 million during its initial release.</p>
  </aside>
  <p>More info about the movie…</p>
</article>
```

#### Result

Technical summary
-----------------

|  |  |
| --- | --- |
| Content categories | Flow content,
 sectioning content,
 palpable content.
  |
| Permitted content | Flow content. |
| Tag omission | None, both the starting and ending tag are mandatory. |
| Permitted parents |
 Any element that accepts
 flow content. Note that an `<aside>` element must not be a
 descendant of an `<address>` element.
  |
| Implicit ARIA role | `complementary` |
| Permitted ARIA roles | `feed`, `none`,
 `note`, `presentation`,
 `region`, `search` |
| DOM interface | `HTMLElement` |

Specifications
--------------

| Specification |
| --- |
| HTML Standard # the-aside-element |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

See also
--------

* Other section-related elements: `<body>`, `<article>`, `<section>`, `<nav>`, h1, h2, h3, h4, h5, h6, `<hgroup>`, `<header>`, `<footer>`, `<address>`;
* Using HTML sections and outlines
* ARIA: Complementary role


<html>: The HTML Document / Root element - HTML: HyperText Markup Language

<html>: The HTML Document / Root element
========================================

The **`<html>`** HTML element represents the root (top-level element) of an HTML document, so it is also referred to as the *root element*. All other elements must be descendants of this element.

|  |  |
| --- | --- |
| Content categories | None. |
| Permitted content |
 One `<head>` element, followed by one
 `<body>` element.
  |
| Tag omission |
 The start tag may be omitted if the first thing inside the
 `<html>` element is not a comment.The end tag may
 be omitted if the `<html>` element is not immediately
 followed by a comment.
  |
| Permitted parents | None. This is the root element of a document. |
| Implicit ARIA role | document |
| Permitted ARIA roles | No `role` permitted |
| DOM interface | `HTMLHtmlElement` |

Attributes
----------

This element includes the global attributes.

`manifest`
Deprecated

Non-standard

Specifies the URI of a resource manifest indicating resources that should be cached locally.

`version`
Deprecated

Specifies the version of the HTML Document Type Definition that governs the current document. This attribute is not needed, because it is redundant with the version information in the document type declaration.

`xmlns`

Specifies the XML Namespace of the document. Default value is `"http://www.w3.org/1999/xhtml"`. This is required in documents parsed with XML parsers, and optional in text/html documents.

Example
-------

```html
<!doctype html>
<html lang="en">
  <head>
    <!-- … -->
  </head>
  <body>
    <!-- … -->
  </body>
</html>
```

Accessibility concerns
----------------------

While HTML does not require authors to specify `<html>` element start and ending tags, it is important for authors to do so as it will allow them to specify the `lang` for the webpage. Providing a `lang` attribute with a valid language tag according to RFC 5646: Tags for Identifying Languages (also known as BCP 47) on the `<html>` element will help screen reading technology determine the proper language to announce. The identifying language tag should describe the language used by the majority of the content of the page. Without it, screen readers will typically default to the operating system's set language, which may cause mispronunciations.

Including a valid `lang` declaration on the `<html>` element also ensures that important metadata contained in the page's `<head>`, such as the page's `<title>`, are also announced properly.

* MDN Understanding WCAG, Guideline 3.1 explanations
* Understanding Success Criterion 3.1.1 | W3C Understanding WCAG 2.1
Specifications
--------------

| Specification |
| --- |
| HTML Standard # the-html-element |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

See also
--------

* MathML top-level element: `<math>`
* SVG top-level element: `<svg>`