…and corresponding (X)HTML markup (abbreviated for clarity):
<form> <input id="element" /> <input /> <input /> </form>
In this example, the first form element (identified by
id="element") will be automatically focused when the document loads, thus facilitating the process of entering data in the form. This technique would serve users well on login pages (wink, wink;), or anywhere forms are required on a repetitive basis.
..and here is a “live” example:
..and corresponding code:
<input onfocus="this.select();" value="Select this element to highlight text.." type="text">
The method discussed in this article doesn’t work as expected in newer versions of Chrome. If that sounds like you, try this snippet instead:
<input onclick="this.select()" type="text" value="Select this element to highlight text..">
So to see that working in Chrome, try the demo:
Let me know if this technique stops working in a future version of Chrome.