HTML5 dramatically expanded form capabilities beyond simple text and password fields. Modern input types include `email` and `url` for automatic format validation, `number` with built-in spinners, `range` for slider controls, `date`, `time`, and `datetime-local` for date and time entry, `color` for a native color picker, `search` for search fields, and `tel` for telephone numbers. The `required` attribute marks a field as mandatory so the browser performs built-in validation and displays a default error message if the field is empty when the form is submitted. For more precise control, the `pattern` attribute applies a regular expression that the entire input value must match, with the `title` attribute providing a human-readable hint that the browser displays when validation fails. The `accept` attribute on file inputs hints which file types the user should be able to select (such as `accept="image/*"` for any image), though it is only a hint and server-side validation remains essential.
Labels tie text descriptions to form controls and are crucial for accessibility. Screen readers announce the label when a user focuses the input, making forms navigable for users who cannot see the screen. The two ways to associate a label with an input are referencing the input's `id` via the `for` attribute, or wrapping the input inside the label itself. Related controls should be grouped with `