WD Lecture 5-Supplementary
WD Lecture 5-Supplementary
Topics: Form
An HTML form is a section of a webpage that allows users to enter and submit data. Forms are used for
tasks like signing up for a newsletter, logging in, submitting feedback, or placing an order. When a user
submits a form, the data is se
nt to a server for processing.
Basic Structure of an HTML Form
An HTML form is created using the <form> element, which can contain various input elements like text fields,
radio buttons, checkboxes, and submit buttons.
Example of a Simple HTML Form:
Common Form Input Types
• POST:
o Appends the form data inside the body of the HTTP request (the submitted form data
is not shown in the URL)
o POST has no size limitations, and can be used to send large amounts of data.
o Form submissions with POST cannot be bookmarked
HTML Input Types:
• <input type="text">
• <input type="number">
• <input type="password">
• <input type="date">
• <input type="email">
• <input type="file">
• <input type="checkbox">
• <input type="radio">
• <input type="reset">
• <input type="search">
• <input type="submit">
• <input type="button">
• <input type="hidden">
• <input type="color">
• <input type="datetime-local">
• <input type="image">
• <input type="month">
• <input type="range">
• <input type="tel">
• <input type="time">
• <input type="url">
• <input type="week">
• Description: Specifies the type of input element. Common values include text, password, email,
number, checkbox, radio, file, submit, etc.
• Example: <input type="text" name="username">
2. name:
• Description: Defines the name of the input element, which is used to identify the data when
the form is submitted.
• Example: <input type="text" name="username">
3. value:
• Description: Specifies the initial value of the input field or the value submitted with the
form.
• Example: <input type="text" name="username" value="JohnDoe">
4. placeholder:
• Description: Provides a short hint that describes the expected value of the input. The hint is
displayed in the input field when it is empty.
• Example: <input type="text" name="username" placeholder="Enter your username">
5. required:
• Description: Indicates that the input field must be filled out before the form can be
submitted.
• Example: <input type="text" name="username" required>
Sample Quiz Questions: