• in
InterCourses
CoursesBlogs
0
← Introduction to HTML
○What is HTML?○Elements, Tags, and Attributes○Your First Complete Page
○Headings and Comments○Paragraphs, Emphasis, and Line Breaks○HTML Lists
○Hyperlinks○Images○Applying Styles to HTML
○Div and Span○HTML Tables○Classes and IDs
○Project 1 - Visiting Card Structure○Project 1 - Visiting Card Actions
○The Head Element and Page Title○Meta Tags○HTML Entities
●HTML Forms○Input Types○Checkboxes and Radio Buttons○Textarea and Select
○Embedding Video○Embedding Audio○Iframes
○Semantic HTML Tags○Details, Figure, and Figcaption
○Project 3 - Resume Semantic Structure○Project 3 - Resume Links and Actions

HTML Forms

Forms allow users to send data to a server — logins, registrations, search boxes, contact forms. Every interactive website uses them.

Basic form structure

html
<form action="/submit" method="post">
    <label for="username">Username</label>
    <input type="text" id="username" name="username" placeholder="e.g. jsmith" />

    <label for="email">Email</label>
    <input type="email" id="email" name="email" placeholder="you@example.com" />

    <button type="submit">Sign Up</button>
</form>

The <form> element

AttributeDescription
actionURL the form data is sent to (defaults to the current page)
methodHTTP method: get (data in URL) or post (data in body)

Use method="post" for any data that modifies the server (logins, registrations, etc.).

Labels and inputs

Always pair every <input> with a <label>:

html
<!-- Linked via for/id -->
<label for="password">Password</label>
<input type="password" id="password" name="password" />

<!-- Or wrap the input inside the label -->
<label>
    Password
    <input type="password" name="password" />
</label>

Linked labels make inputs clickable and are essential for screen reader accessibility.

Common input types

html
<input type="text"     name="name"     placeholder="Full name" />
<input type="email"    name="email"    placeholder="you@example.com" />
<input type="password" name="password" placeholder="Min 8 characters" />
<input type="number"   name="age"      min="0" max="120" />
<input type="submit"   value="Send" />

Other useful attributes

AttributeEffect
requiredField must be filled before submission
placeholderGrey hint text inside the field
valueDefault value for the field
disabledField is visible but not editable
readonlyField is editable but not sent
autocompleteControls browser autofill (on / off)
minlength / maxlengthCharacter limits

Your Task

Build a contact form with:

  1. A <form> with method="post".
  2. A Name field (type="text", required).
  3. An Email field (type="email", required).
  4. A Password field (type="password").
  5. A submit button.
  6. Every input must have a matching <label>.
Hint 1
1 / 4
HINT 1

Every input should have a <label> with a for attribute matching the input's id.

Loading editor…
READY
intercourses
html