| 
									
										
										
										
											2018-10-12 15:37:13 -04:00
										 |  |  | --- | 
					
						
							|  |  |  | title: Input Checked Attribute | 
					
						
							|  |  |  | --- | 
					
						
							|  |  |  | ## Input Checked Attribute
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | The checked attribute is a boolean attribute. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | When present, it specifies that an <input> element should be pre-selected (checked) when the page loads. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | The checked attribute can be used with <input type="checkbox"> and <input type="radio">. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | The checked attribute can also be set after the page load, through JavaScript. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ## Take a look at the following example:
 | 
					
						
							|  |  |  | ```html | 
					
						
							|  |  |  | <form action="/action_page.php"> | 
					
						
							|  |  |  |   <input type="checkbox" name="vehicle" value="Bike"> I have a bike<br> | 
					
						
							|  |  |  |   <input type="checkbox" name="vehicle" value="Car" checked> I have a car<br> | 
					
						
							|  |  |  |   <input type="submit" value="Submit"> | 
					
						
							|  |  |  | </form> | 
					
						
							|  |  |  | ``` | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-11-23 05:17:42 -05:00
										 |  |  | In the example above when the web page is loaded by default the second checkbox will come automatically selected due to the checked attribute. |