| 
									
										
										
										
											2018-10-12 16:00:59 -04:00
										 |  |  | --- | 
					
						
							|  |  |  | title: Autofocus Attribute | 
					
						
							| 
									
										
										
										
											2018-11-01 21:56:08 +03:00
										 |  |  | localeTitle: Атрибут autofocus | 
					
						
							| 
									
										
										
										
											2018-10-12 16:00:59 -04:00
										 |  |  | --- | 
					
						
							| 
									
										
										
										
											2018-11-01 21:56:08 +03:00
										 |  |  | ## Атрибут autofocus | HTML5
 | 
					
						
							| 
									
										
										
										
											2018-10-12 16:00:59 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | Атрибут **autofocus** является логическим атрибутом. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | Когда он присутствует, он указывает, что элемент должен автоматически получать фокус ввода при загрузке страницы. | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-11-01 21:56:08 +03:00
										 |  |  | Только один элемент формы в документе может иметь атрибут **Autofocus** . Он не может применяться к полям `<input type="hidden">` . | 
					
						
							| 
									
										
										
										
											2018-10-12 16:00:59 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | ### Относится к
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-11-01 21:56:08 +03:00
										 |  |  | | Элемент | Атрибут | | 
					
						
							|  |  |  | | :-- | :-- | | 
					
						
							|  |  |  | | `<button>` | autofocus | | 
					
						
							|  |  |  | | `<input>` | autofocus | | 
					
						
							|  |  |  | | `<select>` | autofocus | | 
					
						
							|  |  |  | | `<textarea>` | autofocus | | 
					
						
							| 
									
										
										
										
											2018-10-12 16:00:59 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | ### пример
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ```html | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | <form>  | 
					
						
							|  |  |  |     <input type="text" name="fname" autofocus>  | 
					
						
							|  |  |  |     <input type="text" name="lname">  | 
					
						
							|  |  |  |  </form>  | 
					
						
							|  |  |  | ``` | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ### Совместимость
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | Это атрибут HTML5. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #### Дополнительная информация:
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-11-01 21:56:08 +03:00
										 |  |  | [HTML autofocus Attribute](https://www.w3schools.com/tags/att_autofocus.asp) на w3schools.com | 
					
						
							| 
									
										
										
										
											2018-10-12 16:00:59 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-11-01 21:56:08 +03:00
										 |  |  | [<input> autofocus attribute](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input) на MDN web docs |