HTML Input
Create custom HTML input forms effortlessly with our online generator. Generate code for text fields, checkboxes, radio buttons, and more. Simplify web development with intuitive customization options.
<input type="text" maxlength="10" size="12">
HTML Input Types
Text
HTML text inputs are form elements used to collect textual data from users on a web page. They allow users to enter and edit plain text within a form. Text inputs are defined using the input element with the type attribute set to "text"
Name:
<input type="text" name="name" size="12" required>
Radio buttons
HTML radio inputs are form elements that allow users to select only one option from a list of choices by clicking on circular buttons, ensuring exclusive selection within a group of options.
<label> <input type="radio" name="gender" value="f"> Female </label><br> <label> <input type="radio" name="gender" value="m" checked> Male </label>
Checkbox
Allow users to select one or multiple options from a list of choices by clicking on small boxes, typically representing binary options such as "checked" or "unchecked".
<input type="checkbox" name="checkbox" id="terms"> <label for="terms">Do you accept the terms?</label>
Color
Add a graphical color picker, typically represented by a square box displaying the chosen color and providing options to manually input color values or select from a palette.
Color:
Color: <input type="color" value="#F9425F" name="mycolor">
Date and time
Date and time fields can be used to collect information from users on a web page, providing a user-friendly interface for selecting dates, times, or both, depending on the specific input type chosen.
Date:
Time:
Date: <input type="date" min="2024-01-01"> <br> Time: <input type="time" value="01:30">
Button
Trigger an action or perform a function when clicked by users on a web page, serving as interactive elements to initiate processes such as form submission or JavaScript functions.
<input type="button" value="OK" />
Text HTML Input Types
The input types below resemble text inputs in appearance and behavior but may have specific features or validation related to their intended use.
- number: Allows input of a numeric value. A spinner is typically provided for adjusting the value.
- email: Used for email addresses, with built-in validation for correct email format.
- password: Conceals the input characters for sensitive information such as passwords.
- search: Used for search queries, with additional styling and behavior in some browsers.
- tel: Intended for telephone numbers, though it's similar to a text input and accepts any text input.
- url: Specifically for URLs, providing validation for proper URL format.
HTML Input Tag Attributes
HTML <input> tags can accept a variety of attributes to define their behavior, appearance, and interaction. Some commonly used attributes include:
<input type="text" name="username" id="username" value="John Doe" placeholder="Your name" required maxlength="20" pattern="[A-Za-z]+" autocomplete="username" autofocus style="color: #db3b1d;" />
- type: Specifies the type of input (e.g., text, number, email, etc.).
- name: Identifies the input field when the form is submitted.
- id: Provides a unique identifier for the input element.
- value: Sets the initial value of the input field.
- placeholder: Provides a hint or example text within the input field.
- required: Specifies whether the input field must be filled out before submitting the form.
- disabled: Disables the input field, preventing user interaction.
- readonly: Makes the input field read-only, preventing user edits.
- maxlength: Specifies the maximum number of characters allowed in the input field.
- min and max: Specifies the minimum and maximum allowed values for numeric inputs.
- pattern: Defines a regular expression pattern for validating the input value.
- autocomplete: Specifies whether the browser should automatically complete the input value based on previous inputs or a list of options.
- autofocus: the input field automatically receives focus when the page loads and the page scrolls down if necessary.
- form: Associates the input field with a specific <form> element.
These attributes help customize the behavior and appearance of HTML input tags to suit the requirements of the form and the desired user experience.