The HTML
Use the multiple attribute to allow the user to select more than one value:
The <textarea> element defines a multi-line input field (a text area):
The <fieldset> element is used to group related data in a form.
The <legend> element defines a caption for the <fieldset> element.
<select> tag with size="3" and the multiple attribute.<!DOCTYPE html> <html> <head> <title>Multi Select Example</title> </head> <body> <h2>Allow Multiple Selections</h2> <p>Use the size and multiple attributes to allow users to select more than one value.</p> <form action="/action_page.php"> <label for="skills">Choose skills:</label><br><br> <select id="skills" name="skills" size="3" multiple> <option value="html">HTML</option> <option value="css">CSS</option> <option value="javascript">JavaScript</option> <option value="python">Python</option> </select><br><br> <input type="submit" value="Submit"> </form> </body> </html>
Use the size and multiple attributes to allow users to select more than one value.
<select> element defines a list. size="3" sets the number of visible items, and multiple allows users to hold Ctrl/Cmd to select several options.
<fieldset>, title it with <legend>, and use <textarea> with rows and cols.<!DOCTYPE html> <html> <head> <title>Fieldset and Textarea Example</title> </head> <body> <h2>Grouping Form Data</h2> <form action="/action_page.php"> <fieldset> <legend>User Feedback:</legend> <label for="comments">Your Comments:</label><br> <textarea id="comments" name="comments" rows="4" cols="30">Write your feedback here...</textarea><br><br> <input type="submit" value="Submit"> </fieldset> </form> </body> </html>
<fieldset> tag creates a bordered container, <legend> specifies its caption, and <textarea> provides a multi-line box whose size is defined by rows and cols.
<input list="..."> element to a <datalist id="..."> containing <option> tags.<!DOCTYPE html> <html> <head> <title>Datalist Example</title> </head> <body> <h2>The datalist Element</h2> <p>The datalist element specifies a list of pre-defined options for an input element.</p> <form action="/action_page.php"> <label for="browser">Choose your browser:</label><br> <input list="browsers" name="browser" id="browser"> <datalist id="browsers"> <option value="Edge"> <option value="Firefox"> <option value="Chrome"> <option value="Opera"> <option value="Safari"> </datalist> <input type="submit" value="Submit"> </form> </body> </html>
The datalist element specifies a list of pre-defined options for an input element.
<output> element along with the oninput event attribute in the <form> tag.<!DOCTYPE html> <html> <head> <title>Output Element Example</title> </head> <body> <h2>The output Element</h2> <p>The output element represents the result of a calculation.</p> <form action="/action_page.php" oninput="x.value=parseInt(a.value)+parseInt(b.value)"> 0 <input type="range" id="a" name="a" value="50"> 100 + <input type="number" id="b" name="b" value="50"> = <output name="x" for="a b">100</output><br><br> <input type="submit" value="Submit"> </form> </body> </html>
The output element represents the result of a calculation.
<output> element displays calculated values. The oninput attribute calculates the sum in real time whenever either input changes.