Open In App

When to use the placeholder attribute and the label Element ?

The placeholder attribute and the <label> serve different purposes in providing hints and information for form fields.

placeholder Attribute:

Syntax:

<input type="text" placeholder="Enter your username">

Label Element:

Syntax:

<label for="username">Username:</label>
<input type="text" id="username" name="username">
Article Tags :