HTML Web Forms – Intro to CS Concepts and Programming – Study Notes
offline

Source: Comprehensive Guide to Web Forms and CSS Styling (Texas A&M)

Tags: HTML forms, form element, input types, GET vs POST, radio buttons, checkboxes, select menu, textarea, form controls, form accessibility, fieldset, legend, HTML5 input types, file upload, hidden input, web forms

Difficulty: Beginner to Intermediate Prerequisites: Basic HTML document structure (elements, tags, attributes). If you are not comfortable writing a simple HTML page with headings, paragraphs, and links, review that first.


Big Picture

Web forms are how websites collect information from users, whether that is a login, a search query, a checkout, or a contact message. Every time you fill something in on a website and press "Submit," a form is doing the work behind the scenes. This topic covers the HTML side of building those forms: the elements you use, the attributes that control them, and how data travels from the browser to the server. You will need this knowledge for any project that involves user interaction beyond simple page navigation.


TL;DR

HTML forms wrap a set of input controls inside a

  • The form must use method="POST".

  • The enctype must be multipart/form-data, or the file data will not transmit correctly.

Hidden Controls


These carry data (session tokens, CSRF tokens, state flags) without displaying anything to the user.

Form Accessibility

Labels connect visible text to a control so screen readers can announce what each field is for.

  • Implicit:

  • Explicit:

Fieldset and legend group related controls:

Personal Info

Form Design Best Practices

  • Minimise the number of fields; every extra question increases abandonment.

  • Place labels above fields (research shows this speeds completion).

  • Group related inputs logically with fieldsets.

  • Match the input type to the expected data (email for emails, number for quantities).

  • Make the primary action (Submit) visually prominent; de-emphasise secondary actions (Reset).


Real-World Applications

Every login page, checkout flow, and search bar on the web is built on these form elements. Understanding how name/value pairs travel via GET or POST is also foundational for back-end development and API design, because the server needs to know which variables to expect and how they arrive.


Common Misconceptions

  • "Password fields encrypt the data." They do not. The type="password" attribute only masks the characters on screen. The data is sent as plain text unless the page uses HTTPS.

  • "GET and POST are interchangeable." They are not. GET exposes data in the URL and has size limits; POST keeps data in the request body. Using GET for a login form would put the password in the address bar.

  • "If I omit the name attribute, the data still gets submitted." It does not. A control without name is invisible to the form submission process.

  • "The size attribute on a text input is the best way to control width." It is a rough character-count hint. CSS gives you precise, responsive control and is the preferred approach.


Why It Matters / Exam Flags

⚠️ Know the difference between GET and POST, including when to use each and what happens to the data in the URL.

⚠️ Be able to identify which attribute (name, value, action, method) does what on a form element.

⚠️ Understand that radio buttons in a group must share the same name, and only one can be selected. Checkboxes also share a name for grouping but allow multiple selections.

⚠️ Remember that enctype="multipart/form-data" is required for file uploads.

⚠️ Know the difference between implicit and explicit association.


Quick Self-Test

  1. True or false: The GET method sends data in the body of the HTTP request.

  1. Fill in the blank: To make a file upload work, the form's ________ attribute must be set to multipart/form-data.

  1. True or false: A form control without a name attribute will still send data to the server.

  1. Fill in the blank: Radio buttons in the same group must share the same ________ attribute.

  1. True or false: encrypts the data before transmission.


Practice Q&A

Q: What two attributes are required on a