<!-- 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.
35 lines
1.0 KiB
Markdown
35 lines
1.0 KiB
Markdown
---
|
|
title: Autofocus Attribute
|
|
localeTitle: Atributo de Autofocus
|
|
---
|
|
## Atributo de Autofocus | HTML5
|
|
|
|
El atributo **autofocus** es un atributo booleano.
|
|
|
|
Cuando está presente, especifica que el elemento debe obtener automáticamente el enfoque de entrada cuando se carga la página.
|
|
|
|
Solo un elemento de formulario en un documento puede tener el atributo **autofocus** . No se puede aplicar a `<input type="hidden">` .
|
|
|
|
### Se aplica a
|
|
|
|
| Elemento | Atributo | | : - | : - | | `<button>` | enfoque automático | | `<input>` | enfoque automático | | `<select>` | enfoque automático | | `<textarea>` | enfoque automático |
|
|
|
|
### Ejemplo
|
|
|
|
```html
|
|
|
|
<form>
|
|
<input type="text" name="fname" autofocus>
|
|
<input type="text" name="lname">
|
|
</form>
|
|
```
|
|
|
|
### Compatibilidad
|
|
|
|
Este es un atributo HTML5.
|
|
|
|
#### Más información:
|
|
|
|
[Atributo de autofocus HTML](https://www.w3schools.com/tags/att_autofocus.asp) en w3schools.com
|
|
|
|
[<input> atributo de enfoque automático](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input) en documentos web de MDN |