Super Useful HTML input Attributes
HTML input attributes that are super useful
Hi friend ๐๏ธ
HTML attributes are special words used inside the opening tag to control the element's behaviour. HTML attributes are a modifier of an HTML element type.
I have prepared a list of HTML attributes that are extremely useful in web development.
โ required
This attribute specifies that an element must be filled before submitting the form.
<input type="text" name="username" required>
โ autofocus
It specifies that an element should automatically get focus when the page loads.
<input type="text" id="first_name" name="first_name" autofocus>
โ readonly
This specifies that an input field is read-only.
A read-only input cannot be modified (however, a user can tab to it, highlight it, and copy the text from it).
<input type="text" id="country" name="country" value="Germany" readonly>
โ placeholder
The placeholder attribute specifies a short hint that describes the expected value of an input field (e.g. a sample value or a short description of the expected format).
The short hint is displayed in the input field before the user enters a value.
<input type="tel" id="telephone" name="telephone" placeholder="999-999-9999">
โ maxlength
maxlength attribute specifies maximum number of characters allowed in the element.
<input type="text" id="phone" name="phone" maxlength="10">
โ size
This attribute specifies the width of the input type. Default width size is 20.
<input type="text" id="phone" name="phone" size="50">