All 15 elements together
One small page that uses every element of this section. Turn on Show tags and point at any part of
the page: a label tells you which element draws it. Click to jump to that element's details below.
Forms Written for this site Show tags
Every element of this section is in the page above. Point at one to find it, click it to read its details.
Tags with a dashed border are not drawn on the page: look for them in the code below.
HTML CSS JS
Edit Reset Copy
< form id = "signup" class = "signup" >
< h1 >Join the HTML workshop</ h1 >
< fieldset >
< legend >About you</ legend >
< label for = "name" >Name</ label >
< input id = "name" name = "name" required placeholder = "Ada Lovelace" autocomplete = "name" >
< label for = "email" >Email</ label >
< input id = "email" name = "email" type = "email" required placeholder = "ada@example.com" autocomplete = "email" >
< label for = "city" >City</ label >
< input id = "city" name = "city" list = "cities" placeholder = "Start typing..." >
< datalist id = "cities" >
< option value = "Paris" ></ option >
< option value = "Lyon" ></ option >
< option value = "Montreal" ></ option >
< option value = "Brussels" ></ option >
</ datalist >
</ fieldset >
< fieldset >
< legend >Your workshop</ legend >
< label for = "topic" >Topic</ label >
< select id = "topic" name = "topic" required >
< button type = "button" >< selectedcontent ></ selectedcontent ></ button >
< option value = "" >Choose a topic</ option >
< optgroup label = "Beginners" >
< option value = "html" >๐ฑ HTML basics</ option >
< option value = "css" >๐จ CSS first steps</ option >
</ optgroup >
< optgroup label = "Going further" >
< option value = "forms" >๐ Forms in depth</ option >
< option value = "a11y" >โฟ Accessibility</ option >
</ optgroup >
</ select >
< label for = "seats" >Seats</ label >
< input id = "seats" name = "seats" type = "range" min = "1" max = "5" value = "1" >
< p class = "total" >< output id = "seats-out" for = "seats" >1</ output > seat, total < output id = "total" for = "seats" >20</ output > euros</ p >
< label for = "notes" >Anything to add?</ label >
< textarea id = "notes" name = "notes" rows = "3" placeholder = "Allergies, questions..." ></ textarea >
</ fieldset >
< div class = "gauges" >
< label for = "filled" >Form completed</ label >
< progress id = "filled" max = "3" value = "0" >0 of 3</ progress >
< label for = "places" >Places already taken</ label >
< meter id = "places" min = "0" max = "30" low = "15" high = "25" optimum = "0" value = "24" >24 of 30</ meter >
</ div >
< button type = "submit" >Sign me up</ button >
< p class = "thanks" id = "thanks" hidden >Thanks! This is a demo, nothing was sent.</ p >
</ form > body { margin : 0 ; font-family : system-ui , sans-serif ; color : #1f2937 ; background : #faf5ff ; }
.signup { max-width : 34 rem ; margin : 20 px auto ; display : grid ; gap : 14 px ; background : #fff ; border : 1 px solid #e9d5ff ; border-radius : 18 px ; padding : 24 px 28 px ; }
h1 { margin : 0 ; font-size : 1.6 rem ; }
fieldset { display : grid ; gap : 6 px ; border : 1 px solid #e9d5ff ; border-radius : 12 px ; padding : 12 px 16 px 16 px ; margin : 0 ; }
legend { padding : 0 6 px ; font-weight : 700 ; color : #7e22ce ; }
label { font-weight : 600 ; font-size : 0.9 rem ; margin-top : 6 px ; }
input , textarea , select { font : inherit ; padding : 8 px 12 px ; border : 1 px solid #d8b4fe ; border-radius : 10 px ; background : #fff ; color : inherit ; }
input :focus , textarea :focus , select :focus { outline : 3 px solid #e9d5ff ; border-color : #a855f7 ; }
input [ type = "range" ] { padding : 0 ; accent-color : #a855f7 ; }
input : user-invalid { border-color : #ef4444 ; }
/* Customizable select: browsers that support it draw the button and options with these styles. */
select , ::picker( select ) { appearance : base-select; }
select { display : flex ; justify-content : space-between ; }
::picker( select ) { border : 1 px solid #d8b4fe ; border-radius : 12 px ; padding : 6 px ; }
option { padding : 6 px 10 px ; border-radius : 8 px ; }
option :checked { background : #f3e8ff ; }
optgroup { font-weight : 700 ; color : #7e22ce ; }
.total { margin : 4 px 0 0 ; font-size : 1.1 rem ; }
output { font-weight : 700 ; color : #7e22ce ; }
.gauges { display : grid ; grid-template-columns : max-content 1 fr ; align-items : center ; gap : 8 px 14 px ; }
.gauges label { margin : 0 ; }
progress , meter { width : 100 % ; height : 18 px ; accent-color : #a855f7 ; }
button [ type = "submit" ] { font : inherit ; font-weight : 700 ; padding : 12 px ; border : 0 ; border-radius : 12 px ; background : #9333ea ; color : #fff ; cursor : pointer ; }
button [ type = "submit" ] :hover { background : #7e22ce ; }
.thanks { margin : 0 ; text-align : center ; color : #15803d ; font-weight : 600 ; } const form = document. getElementById ( "signup" );
const seats = document. getElementById ( "seats" );
const required = [ ... form. querySelectorAll ( "[required]" )];
// output shows a computed result; progress counts the required fields already valid.
form. addEventListener ( "input" , () => {
document. getElementById ( "seats-out" ).value = seats.value;
document. getElementById ( "total" ).value = seats.value * 20 ;
document. getElementById ( "filled" ).value = required. filter (( field ) => field. checkValidity ()). length ;
});
form. addEventListener ( "submit" , ( event ) => {
event. preventDefault ();
document. getElementById ( "thanks" ).hidden = false ;
}); Each element in detail WHATWG User-submittable form
MDN The <form> HTML element represents a document section containing interactive controls for submitting information.
Live preview Example from MDN
HTML CSS JS
Edit Reset Copy
Browser support First browser version supporting <form> Chrome 1 Edge 12 Firefox 1 Safari 3 Chrome Android 18 Safari iOS 2
First version with support, from MDN browser-compat-data.
Attributes autocomplete Default setting for autofill feature for controls in the form Value: "on"; "off" rel Not described in the WHATWG attribute index: follow the link to its definition. Also accepts the global attributes .
Specification โ MDN reference โ
WHATWG Caption for a form control
MDN The <label> HTML element represents a caption for an item in a user interface.
Live preview Example from MDN
< div class = "preference" >
< label for = "cheese" >I like cheese.</ label >
< input type = "checkbox" name = "cheese" id = "cheese" />
</ div >
< div class = "preference" >
< label for = "peas" >I like peas.</ label >
< input type = "checkbox" name = "peas" id = "peas" />
</ div > .preference {
display : flex ;
justify-content : space-between ;
width : 60 % ;
margin : 0.5 rem ;
} Browser support First browser version supporting <label> Chrome 1 Edge 12 Firefox 1 Safari โค4 Chrome Android 18 Safari iOS โค3.2
First version with support, from MDN browser-compat-data.
Specification โ MDN reference โ
WHATWG Form control
MDN The <input> HTML element is used to create interactive controls for web-based forms in order to accept data from the user; a wide variety of types of input data and control widgets are available, depending on the device and user agent . The <input> element is one of the most powerful and complex in all of HTML due to the sheer number of combinations of input types and attributes.
Live preview Example from MDN
Browser support First browser version supporting <input> Chrome 1 Edge 12 Firefox 1 Safari 1 Chrome Android 18 Safari iOS 1
First version with support, from MDN browser-compat-data.
Attributes alt Replacement text for use when images are not available Value: Text * form Associates the element with a form element Value: ID * list List of autocomplete options Value: ID * max Maximum value Value: Varies* min Minimum value Value: Varies* pattern Pattern to be matched by the form control's value Value: Regular expression matching the JavaScript Pattern production placeholder User-visible label to be placed within the form control Value: Text * popovertarget Targets a popover element to toggle, show, or hide Value: ID * value Value of the form control Value: Varies* Also accepts the global attributes .
Specification โ MDN reference โ
WHATWG Button control
MDN The <button> HTML element is an interactive element activated by a user with a mouse, keyboard, finger, voice command, or other assistive technology. Once activated, it then performs an action, such as submitting a form or opening a dialog.
Live preview Example from MDN
Browser support First browser version supporting <button> Chrome 1 Edge 12 Firefox 1 Safari 1 Chrome Android 18 Safari iOS 1
First version with support, from MDN browser-compat-data.
Specification โ MDN reference โ
WHATWG List box control
MDN The <select> HTML element represents a control that provides a menu of options.
Live preview Example from MDN
< label for = "pet-select" >Choose a pet:</ label >
< select name = "pets" id = "pet-select" >
< option value = "" >--Please choose an option--</ option >
< option value = "dog" >Dog</ option >
< option value = "cat" >Cat</ option >
< option value = "hamster" >Hamster</ option >
< option value = "parrot" >Parrot</ option >
< option value = "spider" >Spider</ option >
< option value = "goldfish" >Goldfish</ option >
</ select > label {
font-family : sans-serif ;
font-size : 1 rem ;
padding-right : 10 px ;
}
select {
font-size : 0.9 rem ;
padding : 2 px 5 px ;
} Browser support First browser version supporting <select> Chrome 1 Edge 12 Firefox 1 Safari 1 Chrome Android 18 Safari iOS 1
First version with support, from MDN browser-compat-data.
Specification โ MDN reference โ
WHATWG Container for options for combo box control
MDN The <datalist> HTML element contains a set of <option> elements that represent the permissible or recommended options available to choose from within other controls.
Live preview Example from MDN
< label for = "ice-cream-choice" >Choose a flavor:</ label >
< input list = "ice-cream-flavors" id = "ice-cream-choice" name = "ice-cream-choice" />
< datalist id = "ice-cream-flavors" >
< option value = "Chocolate" ></ option >
< option value = "Coconut" ></ option >
< option value = "Mint" ></ option >
< option value = "Strawberry" ></ option >
< option value = "Vanilla" ></ option >
</ datalist > label {
display : block ;
margin-bottom : 10 px ;
} Browser support First browser version supporting <datalist> Chrome 20 Edge 12 Firefox 4 Safari 12.1 Chrome Android 33 Safari iOS 12.2
First version with support, from MDN browser-compat-data.
Specification โ MDN reference โ
WHATWG Group of options in a list box
MDN The <optgroup> HTML element creates a grouping of options within a <select> element.
Live preview Example from MDN
< label for = "dino-select" >Choose a dinosaur:</ label >
< select id = "dino-select" >
< optgroup label = "Theropods" >
< option >Tyrannosaurus</ option >
< option >Velociraptor</ option >
< option >Deinonychus</ option >
</ optgroup >
< optgroup label = "Sauropods" >
< option >Diplodocus</ option >
< option >Saltasaurus</ option >
< option >Apatosaurus</ option >
</ optgroup >
</ select > label {
display : block ;
margin-bottom : 10 px ;
} Browser support First browser version supporting <optgroup> Chrome 1 Edge 12 Firefox 1 Safari โค4 Chrome Android 18 Safari iOS โค3.2
First version with support, from MDN browser-compat-data.
Specification โ MDN reference โ
WHATWG Option in a list box or combo box control
MDN The <option> HTML element is used to define an item contained in a <select> , an <optgroup> , or a <datalist> element. As such, <option> can represent menu items in popups and other lists of items in an HTML document.
Live preview Example from MDN
< label for = "pet-select" >Choose a pet:</ label >
< select id = "pet-select" >
< option value = "" >--Please choose an option--</ option >
< option value = "dog" >Dog</ option >
< option value = "cat" >Cat</ option >
< option value = "hamster" >Hamster</ option >
< option value = "parrot" >Parrot</ option >
< option value = "spider" >Spider</ option >
< option value = "goldfish" >Goldfish</ option >
</ select > label {
font-family : sans-serif ;
font-size : 1 rem ;
padding-right : 10 px ;
}
select {
font-size : 0.9 rem ;
padding : 2 px 5 px ;
} Browser support First browser version supporting <option> Chrome 1 Edge 12 Firefox 1 Safari โค4 Chrome Android 18 Safari iOS โค3.2
First version with support, from MDN browser-compat-data.
Specification โ MDN reference โ
WHATWG Multiline text controls
MDN The <textarea> HTML element represents a multi-line plain-text editing control, useful when you want to allow users to enter a sizeable amount of free-form text, for example a comment on a review or feedback form.
Live preview Example from MDN
< label for = "story" >Tell us your story:</ label >
< textarea id = "story" name = "story" rows = "5" cols = "33" >
It was a dark and stormy night...
</ textarea > label ,
textarea {
font-size : 0.8 rem ;
letter-spacing : 1 px ;
}
textarea {
padding : 10 px ;
max-width : 100 % ;
line-height : 1.5 ;
border-radius : 5 px ;
border : 1 px solid #cccccc ;
box-shadow : 1 px 1 px 1 px #999999 ;
}
label {
display : block ;
margin-bottom : 10 px ;
} Browser support First browser version supporting <textarea> Chrome 1 Edge 12 Firefox 1 Safari โค4 Chrome Android 18 Safari iOS โค3
First version with support, from MDN browser-compat-data.
Specification โ MDN reference โ
WHATWG Calculated output value
MDN The <output> HTML element is a container element into which a site or app can inject the results of a calculation or the outcome of a user action.
Live preview Example from MDN
< input type = "range" id = "b" name = "b" value = "50" /> +
< input type = "number" id = "a" name = "a" value = "10" /> =
< output id = "result" for = "a b" >60</ output > const a = document. getElementById ( "a" );
const b = document. getElementById ( "b" );
const result = document. getElementById ( "result" );
function updateResult () {
const aValue = a.valueAsNumber;
const bValue = b.valueAsNumber;
result.value = aValue + bValue;
}
a. addEventListener ( "input" , updateResult);
b. addEventListener ( "input" , updateResult);
updateResult (); Browser support First browser version supporting <output> Chrome 10 Edge โค18 Firefox 4 Safari 7 Chrome Android 18 Safari iOS 7
First version with support, from MDN browser-compat-data.
Specification โ MDN reference โ
WHATWG Progress bar
MDN The <progress> HTML element displays an indicator showing the completion progress of a task, typically displayed as a progress bar.
Live preview Example from MDN
< label for = "file" >File progress:</ label >
< progress id = "file" max = "100" value = "70" >70%</ progress > label {
padding-right : 10 px ;
font-size : 1 rem ;
} Browser support First browser version supporting <progress> Chrome 6 Edge 12 Firefox 6 Safari 6 Chrome Android 18 Safari iOS 8
First version with support, from MDN browser-compat-data.
Specification โ MDN reference โ
WHATWG Gauge
MDN The <meter> HTML element represents either a scalar value within a known range or a fractional value.
Live preview Example from MDN
< label for = "fuel" >Fuel level:</ label >
< meter id = "fuel" min = "0" max = "100" low = "33" high = "66" optimum = "80" value = "50" >
at 50/100
</ meter > label {
padding-right : 10 px ;
font-size : 1 rem ;
} Browser support First browser version supporting <meter> Chrome 6 Edge 13 Firefox 16 Safari 6 Chrome Android 18 Safari iOS 10.3
First version with support, from MDN browser-compat-data.
Specification โ MDN reference โ
WHATWG Group of form controls
MDN The <fieldset> HTML element is used to group several controls as well as labels (<label> ) within a web form.
Live preview Example from MDN
< form >
< fieldset >
< legend >Choose your favorite monster</ legend >
< input type = "radio" id = "kraken" name = "monster" value = "K" />
< label for = "kraken" >Kraken</ label >< br />
< input type = "radio" id = "sasquatch" name = "monster" value = "S" />
< label for = "sasquatch" >Sasquatch</ label >< br />
< input type = "radio" id = "mothman" name = "monster" value = "M" />
< label for = "mothman" >Mothman</ label >
</ fieldset >
</ form > legend {
background-color : black ;
color : white ;
padding : 3 px 6 px ;
}
input {
margin : 0.4 rem ;
} Browser support First browser version supporting <fieldset> Chrome 1 Edge 12 Firefox 1 Safari โค4 Chrome Android 18 Safari iOS โค3.2
First version with support, from MDN browser-compat-data.
Specification โ MDN reference โ
WHATWG Caption for fieldset
MDN The <legend> HTML element represents a caption for the content of its parent <fieldset> .
Live preview Example from MDN
< fieldset >
< legend >Choose your favorite monster</ legend >
< input type = "radio" id = "kraken" name = "monster" value = "K" />
< label for = "kraken" >Kraken</ label >< br />
< input type = "radio" id = "sasquatch" name = "monster" value = "S" />
< label for = "sasquatch" >Sasquatch</ label >< br />
< input type = "radio" id = "mothman" name = "monster" value = "M" />
< label for = "mothman" >Mothman</ label >
</ fieldset > legend {
background-color : black ;
color : white ;
padding : 3 px 6 px ;
}
input {
margin : 0.4 rem ;
} Browser support First browser version supporting <legend> Chrome 1 Edge 12 Firefox 1 Safari 3 Chrome Android 18 Safari iOS 1
First version with support, from MDN browser-compat-data.
Specification โ MDN reference โ
WHATWG Mirrors content from an option
MDN The <selectedcontent> HTML is used inside a <select> element to display the contents of its currently selected <option> within its first child <button> . This enables you to style all parts of a <select> element, referred to as "customizable selects ".
Browser support First browser version supporting <selectedcontent> Chrome 135 Edge 135 Firefox No Safari 27 Chrome Android 135 Safari iOS 27
First version with support, from MDN browser-compat-data.
Specification โ MDN reference โ