HTML disabled Attribute


The disabled attribute of the <input> element is used to disable <input> element. When an element is disabled, it becomes unclickable. For obvious reasons, the disabled input element won’t get submitted.

Syntax

Following is the syntax −

<input disabled>

Let us now see an example to implement the disabled attribute of the <input> element −

Example

 Live Demo

<!DOCTYPE html>
<html>
<body>
<h2>Details</h2>
<form>
<p>These are the new details...</p>
<fieldset>
<legend>New Details:</legend>
Player: <input type="text" disabled><br>
Rank: <input type="number"><br>
Email: <input type="email"><br>
Reporting Time: <input type="time">
</fieldset>
</form>
</body>
</html>

Output

This will produce the following output wherein we have disabled one of the input element “Player” −

In the above example, we have four fields −

Player: <input type="text" disabled><br>
Rank: <input type="number"><br>
Email: <input type="email"><br>
Reporting Time: <input type="time">

Out of the above four fields we have disabled one of them using the disabled attribute −

Player: <input type="text" disabled>

Now in the above fields you won’t be able to add any text, since it is disabled.

Updated on: 16-Sep-2019

162 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements