HTML Input Attributes

HTML provides a variety of attributes that can be used with the `<input>` element to customize its behavior and appearance. Here are some commonly used input attributes in HTML:


1. `type`: Specifies the type of input. This attribute is required and determines the kind of data that can be entered or selected. For example, `type="text"`, `type="email"`, `type="password"`, etc.

2. `name`: Specifies the name of the input field. This attribute is used to identify the input when the form is submitted and is often used in server-side processing.

3. `value`: Specifies the initial value of the input field. It can be pre-filled with a default value or used to display the current value.

4. `placeholder`: Specifies a short hint or example text that is displayed in the input field before the user enters a value.

5. `required`: Specifies that the input field must be filled in before the form can be submitted.

6. `disabled`: Disables the input field, making it uneditable and preventing its value from being submitted with the form.

7. `readonly`: Makes the input field read-only, allowing users to view the value but not edit it.

8. `min` and `max`: Specifies the minimum and maximum values allowed for numeric input types, such as `number`, `range`, or `date`.

9. `step`: Specifies the increment or decrement step for numeric input types, such as `number` or `range`.

10. `autocomplete`: Specifies whether the browser should autocomplete the input field. Values can be set to "on" or "off".

11. `autofocus`: Specifies that the input field should automatically receive focus when the page loads.

12. `pattern`: Specifies a regular expression pattern that the entered value must match for the input to be considered valid.

13. `maxlength`: Specifies the maximum number of characters allowed for text input fields.

14. `size`: Specifies the width, in characters, of the input field.



These are just a few examples of the input attributes available in HTML. There are additional attributes specific to certain input types, such as `multiple` for selecting multiple files, `checked` for pre-selecting checkboxes or radio buttons, and more. The choice of attributes depends on the type of input and the desired functionality for your form.



About the Author



Silan Software is one of the India's leading provider of offline & online training for Java, Python, AI (Machine Learning, Deep Learning), Data Science, Software Development & many more emerging Technologies.

We provide Academic Training || Industrial Training || Corporate Training || Internship || Java || Python || AI using Python || Data Science etc





 PreviousNext