The input autofocus attribute dictates that an input field should automatically receive focus upon page load.
Example
Ensure that the “First name” input field receives focus automatically when the page loads.
<form> <label for=”fname”>First name:</label><br> <input type=”text” id=”fname” name=”fname” autofocus><br> <label for=”lname”>Last name:</label><br> <input type=”text” id=”lname” name=”lname”> </form> |
The height and width attributes of an <input type=”image”> element determine its height and width.
Tip: It’s essential to specify both the height and width attributes for images. When both are set, the required space for the image is reserved upon page load. Without these attributes, the browser cannot determine the image size and won’t reserve the necessary space, leading to potential layout shifts during loading as images load. |
Example
Specify an image as the submit button, providing height and width attributes:
<form> <label for=”fname”>First name:</label> <input type=”text” id=”fname” name=”fname”><br><br> <label for=”lname”>Last name:</label> <input type=”text” id=”lname” name=”lname”><br><br> <input type=”image” src=”img_submit.gif” alt=”Submit” width=”48″ height=”48″> </form> |