HTML disabled Attribute


The disabled attribute in HTML is used to disable an element. Use this attribute on the following elements −

<button>, <textarea>, <optgroup>, <select>, <fieldset>, <input>, and <option>.

Following is the syntax −

<element disabled>

The above element will get disabled since we have set it disabled.

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

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.

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” −

Updated on: 29-Jun-2020

146 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements