Files
freeCodeCamp/mock-guide/english/html/attributes/autofocus-attribute/index.md
Stuart Taylor 7da04a348b fix: Update packages and fix local dev (#26907)
<!-- Please follow this checklist and put an x in each of the boxes, like this: [x]. It will ensure that our team takes your pull request seriously. -->

- [x] I have read [freeCodeCamp's contribution guidelines](https://github.com/freeCodeCamp/freeCodeCamp/blob/master/CONTRIBUTING.md).
- [x] My pull request has a descriptive title (not a vague title like `Update index.md`)
- [x] My pull request targets the `master` branch of freeCodeCamp.
2018-10-23 18:48:46 +05:30

38 lines
919 B
Markdown

---
title: Autofocus Attribute
---
## Autofocus Attribute | HTML5
The **autofocus** attribute is a boolean attribute.
When present, it specifies that the element should automatically get input focus when the page loads.
Only one form element in a document can have the **autofocus** attribute. It cannot be applied to `<input type="hidden">`.
### Applies to
| Element | Attribute |
| :-- | :-- |
| `<button>` | autofocus |
| `<input>` | autofocus |
| `<select>` | autofocus |
| `<textarea>` | autofocus |
### Example
```html
<form>
<input type="text" name="fname" autofocus>
<input type="text" name="lname">
</form>
```
### Compatibility
This is an HTML5 attribute.
#### More Information:
[HTML autofocus Attribute](https://www.w3schools.com/tags/att_autofocus.asp) on w3schools.com
[&lt;input&gt; autofocus attribute](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input) on MDN web docs