I don't want the user to have to click the first text box to write on it. When the page is loaded, I want the text input to be preselected.
Use the autofocus attribute inside your html element.
In this example, you can see the "First name" input has autofocus, and it will be automatically selected when the page loads, so the user can type straight away:
<!DOCTYPE html>
<html>
<body>
<form action="demo_form.asp">
First name: <input type="text" name="fname" autofocus><br>
Last name: <input type="text" name="lname"><br>
<input type="submit">
</form>
</body>
</html>
The autofocus attribute, of the input tag, is not supported in Internet Explorer 9 and earlier versions.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With