Date: 11-26-24 and 11-30-24
This chapter describes all the different HTML form elements.
The HTML <form> elements can contain one or more of the following form elements:
One of the most used form elements is the <input> element. The <input>element can be displayed in several ways, depending on the type attribute.
The <label> element defines a label for several form elements. The <label> element is useful for screen-reader users, because the screen-reader willl read out loud the label when the user focus on the input element. The <label> element is useful for screen-reader users, because the screen-reader will read out loud the label when the user focus on the input element. The <label> element also help users who have diffculty clicking on very small regions (such as radio buttons or checkboxs) - because when the user clicks the text within the <label> element, it toggles the radio button/checkbox. The for attribute of the <label> tag should be eaqual to the id attribute of the <input> element to bind them together.
The <select> element defines a drop-down list:
The <option> element defines an option that can be selected. By default, the first item in the drop-down list is selected. To define a pre-selected option, add the selected attribute to the option:
You can preselect an option with the selected attribute:
https://www.w3schools.com/html/html_emojis.aspUse the size attribute to specify the number of visible values:
Use the multiple attribute to allow the user to select more than one value:
The rows attribute specifies the visible number of lines in a text area. The cols attribute specifies the visible width of a text area. This is how the HTML code above will be displayed in a browser:
You can also define the size of the text area by using CSS:
The <button> defines a clickable button:
This is how the HTML code above will be displayed in a browser:
Note: Always specify the type attribute for the button element. Different browsers may use different default types for the button element.
The <fieldset> element is used to group related data in a form. The <legend> element defines a caption for the <fieldset> element.
This ishow the code above will be displayed in a browser:
The <datalist> element specifies a list of pre-defined options for an <input> element. Users will see a drop-down list of the pre-defined options as they input data. The list attribute of the <input> element, must refer to the id attribute of the <datalist> element.
The datalist element specifies a list of pre-defined options for an input element.
The <ouput> element repesents the result of a calculation (like one performed by a script).
The output element represents the result of a calculation.