submit
button or the Enter
keyGET
and POST
input
, label
, select
, and button
are coveredmethod
and action
attributes of the form tag are used to specify the submission method and destination respectivelyfieldset
and legend
tags to group related input fieldslabel
tag should always be used with input fields to make them more accessible to screen readersemail
, url
, date
, etc.required
, min
, and max
can also be used to validate inputscript
tagaddEventListener
method can be used to attach event listeners to HTML elementsclick
, keydown
, submit
, etc. are listed with their respective event objectsForms are a key way for users to interact with websites and provide data input.
Key things to consider include making the form easy to use, organizing it logically, using appropriate form elements, providing feedback, and designing for different devices.
input
: collects text, numbers, and data from userslabel
: provides a description or name for an input field, making it accessible to screen readersselect
: creates drop-down menus with predefined optionsradio buttons
: presents mutually exclusive optionstextarea
: collects longer text inputs, such as comments or feedbackEvents are actions that happen in the browser when a user interacts with a website, such as clicking on buttons, typing in text fields, or scrolling the page.
The type of event you want to listen for, and a function to execute when the event occurs.
The event object contains information about an event that has occurred, including the type of event, the target element that triggered the event, and additional data. The target is useful for accessing the element that triggered the event.
Event bubbling starts at the lowest level element and “bubbles up,” while event capturing starts at the highest level element and “captures” the event as it propagates down to the lowest level element.