https://www.htmhell.dev/adventcalendar/2023/8/ Skip to content 1. Hell 2. Heaven 3. Newsletter 4. Advent Calendar 5. HTMHell on Twitter 6. HTMHell homepage The hidden depths of the input element by Phil Nash published on Dec 08, 2023 The element is the most fascinating element in HTML. Most elements behave the same way regardless of their attributes, the type attribute of the element can take 1 of 22 different values that gives it not only different behaviour, but a different visual appearance too (many of which are hell to style, of course). The element is responsible for everything from text input, through checkboxes and radio buttons, to a button that resets all other elements in the form. I want to look beyond the various types that the can embody, to the attributes you may not know about. Attributes that tweak the behaviour of the to make it more usable, more accessible, and more applicable to various situations. Let's dig in. Keyboard control On a mobile device, focusing a text input will bring up the default virtual keyboard. But what if the input you are expecting is numerical or some other format? In this case the inputmode attribute can help to optimise the keyboard for the input you are expecting. If the expected input is an email address, you can set the inputmode to "email" and the @ symbol will surface on the main keyboard. If, however, you're looking for a number, then you can set the inputmode to "numeric" or "decimal" and the number keypad will appear. This is useful in cases where your input is a number, but the input type of number isn't appropriate, for example with a one time password or a credit card number. The full list of inputmode values that you can use are listed below with their keyboard appearance on iOS. Android will display different variations. * none: stops virtual keyoards appearing for when you want to implement your own keyboard (you probably don't want this) * text: the default * numeric: just numbers * decimal: numbers and a decimal point * tel: numbers and other dial pad characters * url: the normal keyboard, with a period, forward slash and ".com" in place of the space bar * email: the normal keyboard, with a small space bar, an "@" symbol and a period * search: the normal keyboard, with a slightly smaller space bar, a period and a highlighted button that says "go" rather than the normal "return" An animation showing a browser on iOS tabbing through the different inputmodes, appearing as listed above. inputmode is also supported on