Skip to content
    SeaCode
    Learning tracksCode ArenaWorkshops & EventsInstructors
    Log inSign up
    </>HTML

    Document foundations

    • What is HTML?
    • Metadata and language
    • Attributes and character references
    • Headings, paragraphs and formatting

    Content and media

    • Links
    • Images
    • Lists
    • Tables
    • Responsive images and media

    Forms

    • Forms and inputs
    • Grouping form controls
    • Form validation and submission

    Structure and accessibility

    • Semantic HTML
    • Keyboard and screen-reader access
    • Disclosure with details
    • Project: your profile page
    HTML

    Forms · Lesson 10 of 16

    Forms and inputs

    Collect data from visitors: text, email and choices.

    8 minutes3 games

    <form> groups inputs. <input> is a field whose kind is set by type: text, email, password, number, checkbox. <label> names a field and links to it with for matching the field's id.

    HTML
    <form>
      <p>
        <label for="name">Name</label><br>
        <input id="name" type="text" placeholder="Your name" required>
      </p>
      <p>
        <label for="email">Email</label><br>
        <input id="email" type="email">
      </p>
      <p>
        <label><input type="checkbox"> Send me news</label>
      </p>
      <button type="submit">Join</button>
    </form>

    Try clicking Join with no name: required blocks it.

    Important

    A field needs name for its value to be submitted. id links a label and is not a replacement for name.

    Interview question

    Can a placeholder replace a label?

    Link every field to a label. Clicking the label focuses the field, and screen readers announce its name.

    Quick question

    Which type is for a password field?

    Complete the code

    Link the label to the field.

    <label ="age">Age</label>
    <input ="age" type="number">

    Exercise

    Make a form with a labelled email field and a button.

    HTML
    <form>
    
    </form>
    

    Field name

    User value

    Request data

    Server validation

    Learn more from

    • MDN: HTML referencedeveloper.mozilla.org
    • web.dev: formsweb.dev

    Played 0 of 3 games

    Sign in to save your progress and earn XP.

    PreviousResponsive images and mediaNextGrouping form controls
    SeaCode

    Learn to code for real, online or at our branch in front of Cairo University, Giza.

    Learn

    • All courses
    • Interactive tutorials
    • Interview practice problems
    • Mock interview
    • Learning tracks
    • Code Arena
    • Workshops & Events
    • Knowledge library
    • Team projects

    Your account

    • Log in
    • Sign up
    • Learning plan
    • Certificates
    • Site map

    Contact us

    • WhatsApp
    • 010 9094 1104
    • In front of Cairo University, Giza

    © 2026 SeaCode. All rights reserved.