HTML Forms
Forms are used to collect user input, such as text, selections, and file uploads.
Form Syntax
Form Elements
<form>: Defines the form<label>: Defines a label for an input<input>: Defines an input field<button>: Defines a submit button
Input Types
text: Single-line text inputpassword: Password inputemail: Email inputcheckbox: Checkbox inputradio: Radio button inputfile: File upload inputsubmit: Submit button
Form Attributes
action: Specifies the form handler URLmethod: Specifies the form submission method (GET or POST)enctype: Specifies the encoding type for file uploads
Example Form
Form Best Practices
- Use
<label>elements to associate labels with inputs. - Use the
nameattribute to identify form inputs. - Use the
actionandmethodattributes to specify form submission. - Use the
enctypeattribute for file uploads.
Tags
html coding