HTML - attributes - multiple

revision:


Content

"multiple" attribute : a boolean attribute that allows more values syntax some examples


"multiple" attribute : a boolean attribute that allows more values

top

When present, it specifies that the user is allowed to enter more than one value in the <input> and <select> element. Valid for the "email" and "file" input types and the <select> element, the manner by which the user opts for multiple values depends on the form control.


syntax

top

<input multiple>

<select multiple></select>

For <input type="file">: to select multiple files, hold down the CTRL or SHIFT key while selecting.

For <input type="email">: separate each email with a comma - like: [email protected], [email protected], [email protected] - in the email field.


some examples

top

Try selecting more than one file when browsing for files.



codes:
                    <form style="margin-left:3vw;" action="/action_page.php">
                        <label for="files">Select files:</label>
                        <input type="file" id="files" name="files" multiple><br><br>
                        <input type="submit">
                    </form>
                


Hold down the Ctrl (windows) or Command (Mac) button to select multiple options.

codes:
                    <form style="margin-left:3vw;"  action="/action_page.php">
                        <label for="cars">Choose a car:</label>
                        <select name="cars" id="cars" multiple>
                        <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">
                    </form>