HTML <input> form Attribute

Example An input field located outside the HTML form (but still a part of the form): <form action=”/action_page.php” id=”form1″> First name: <input type=”text” name=”fname”><br> <input type=”submit” value=”Submit”> </form>Last name: <input type=”text” name=”lname” form=”form1″> Try it Yourself » Definition and Usage The form attribute specifies one or more forms the <input> element belongs to. Browser Support The numbers in the table specify the first browser version that […]

HTML <input> disabled Attribute

Example An HTML form with a disabled input field: <form action=”/action_page.php”> First name: <input type=”text” name=”fname”><br> Last name: <input type=”text” name=”lname” disabled><br> <input type=”submit” value=”Submit”> </form> Try it Yourself » Definition and Usage The disabled attribute is a boolean attribute. When present, it specifies that the <input> element should be disabled. A disabled input element is unusable and un-clickable. The disabled attribute can be set […]

HTML <input> dirname Attribute

Example An HTML form where the field’s text direction will be submitted: <form action=”/action_page.php”> First name: <input type=”text” name=”fname” dirname=”fname.dir”> <input type=”submit” value=”Submit”> </form> Try it Yourself » Definition and Usage The dirname attribute enables the submission of the text direction of the input field The dirname attribute’s value is always the name of the input field, followed by “.dir”. Browser Support […]

HTML <input> checked Attribute

Example An HTML form with a pre-selected checkbox: <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> Try it Yourself » Definition and Usage 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 […]

HTML <input> autofocus Attribute

Example Let the “First name” input field automatically get focus when the page loads: <form action=”/action_page.php”> First name: <input type=”text” name=”fname” autofocus><br> Last name: <input type=”text” name=”lname”><br> <input type=”submit”> </form> Try it Yourself » Definition and Usage The autofocus attribute is a boolean attribute. When present, it specifies that an <input> element should automatically get focus when the page loads. Browser Support The numbers […]

HTML <input> autocomplete Attribute

Example An HTML form with autocomplete on (and off for one input field): <form action=”/action_page.php” autocomplete=”on”> First name:<input type=”text” name=”fname”><br> Last name: <input type=”text” name=”lname”><br> E-mail: <input type=”email” name=”email” autocomplete=”off”><br> <input type=”submit”> </form> Try it Yourself » Definition and Usage The autocomplete attribute specifies whether or not an input field should have autocomplete enabled. Autocomplete allows the browser to predict the value. When a user starts to […]

HTML <input> alt Attribute

Example An HTML form with an image that represents the submit button: <form action=”/action_page.php”> First name: <input type=”text” name=”fname”><br> <input type=”image” src=”submit.gif” alt=”Submit” width=”48″ height=”48″> </form> Try it Yourself » Definition and Usage The alt attribute provides an alternate text for the user, if he/she for some reason cannot view the image (because of slow connection, an error in the src attribute, or if […]

HTML <input> accept Attribute

Example Specify that the server accepts only image files in the file upload: <form action=”/action_page.php”> <input type=”file” name=”pic” accept=”image/*”> <input type=”submit”> </form> Try it Yourself » Definition and Usage The accept attribute specifies the types of files that the server accepts (that can be submitted through a file upload). Note: The accept attribute can only be used with <input type=”file”>. Tip: Do […]

HTML <div> Tag

Example A section in a document that will have a light blue background color: <div style=”background-color:lightblue”> <h3>This is a heading</h3> <p>This is a paragraph.</p> </div> Try it Yourself » Definition and Usage The <div> tag defines a division or a section in an HTML document. The <div> element is often used as a container for other […]