Super Useful HTML input Attributes

Super Useful HTML input Attributes

HTML input attributes that are super useful

ยท

2 min read

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">



I hope this information can help you in your dev journey



ย