Zed-King Institute

    HTML Registration Form Example with Input Types

    mediumFormsHTML

    Forms collect information from users. This one uses every input type the M2 practical usually asks for.

    The question

    Create a form with: a text box for name (required), an email box, a password box, a dropdown (<select>) with the courses O Level, Python, BCC, Digital Marketing, two radio buttons named gender (Male, Female) and a submit button.

    The code

    index.html

    <form>
      <p>Name: <input type="text" name="name" required></p>
      <p>Email: <input type="email" name="email"></p>
      <p>Password: <input type="password" name="pwd"></p>
      <p>Course:
        <select name="course">
          <option>O Level</option>
          <option>Python</option>
          <option>BCC</option>
          <option>Digital Marketing</option>
        </select>
      </p>
      <p>Gender:
        <input type="radio" name="gender" value="M"> Male
        <input type="radio" name="gender" value="F"> Female
      </p>
      <input type="submit" value="Register">
    </form>

    Result

    How it works

    1. 1type="text", "email" and "password" give different boxes; email is checked by the browser, password hides what you type.
    2. 2required stops the form from submitting while the box is empty.
    3. 3<select> with <option> tags makes a dropdown.
    4. 4Radio buttons with the same name form one group — only one can be chosen.

    Common mistakes

    • Giving each radio button a different name, so both can be selected at once.
    • Leaving the controls outside the <form> tag.

    Now solve a similar question yourself

    A new HTML / CSS / JS question every time, checked instantly.

    Practice questions