Today I Learned - Rocky Kev

TIL the multiple value in html

POSTED ON:

TAGS:

The multiple attribute allows the user to enter multiple values on an <input>. It is a boolean attribute valid for file or email input types and the <select> element.

On a <select>

Most browsers displaying a scrolling list box for a <select> control with the multiple attribute set versus a single line dropdown when the attribute is omitted.

  <select multiple name="cars" id="cars">
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
<option value="opel">Opel</option>
<option value="audi">Audi</option>
</select>
<br><br>
<input type="submit" value="Submit">

See the Pen Untitled by rockykev (@rockykev) on CodePen.

on a input type="email"

For an email input, if and only if the multiple attribute is specified, the value can be a list of comma-separated email addresses. Any whitespace is removed from each address in the list.

<input type="email" multiple name="emails" id="emails">

The email input displays the same, but will match the :invalid pseudo-class if more than one comma-separated email address is included if the attribute is not present.

on a input type="file"

When multiple is set on the file input type, the user can select one or more files. The user can choose multiple files from the file picker in any way that their chosen platform allows (e.g. by holding down Shift or Control, and then clicking).

<input type="file" multiple>

MDN Multiple


Related TILs

Tagged:

TIL Gmail has a 102KB size-limit for HTML

PLACEHOLDER

TIL how Error correction works in HTML

You never get an 'Invalid Syntax' error on an HTML page. Browsers fix any invalid content and go on.

TIL what DOCTYPE means

tl;dr: DOCTYPE declaration in the first line of the HTML file, to instruct the browser to run the code in Standard mode.