Advertisement
Home Open Editor ❯

HTML <select> autofocus Attribute

Example

<label for="lang">Choose your option:</label>

<select name="language" id="lang" autofocus>
  <option value="HTML">HTML</option>
  <option value="CSS">CSS</option>
  <option value="JavaScript">JavaScript</option>
</select>

Try this code ❯

Meaning

The autofocus attribute is used to indicate that the user agent should immediately focus this form item once its containing window loads.


Standard Syntax

<select autofocus>
  <option>text</option>
</select>


Advertisement

Attribute Values

Value Description
autofocus This is a boolean attribute, the presence of a boolean attribute on an element represents the true value, and the absence of the attribute represents the false value.
Home Open Editor ❯
Advertisement