Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

html
communitycreator

What is a disabled attribute in HTML?

Gutha Vamsi Krishna

While filling in forms on web pages, we may want to restrict the user from changing the value of the input element until some other condition has been met, or we may want to restrict some buttons to the users who don’t have sufficient access to specific functionalities.

To do this, we have the disabled attribute in HTML for the input element. When we apply the disabled attribute to the input element, it will become unusable and unclickable.

We can use the following syntax for enabling this attribute:

Syntax

<input disabled>

Let’s look at an example.

Example

In the following example, we create two buttons:

  • In line 8, we create a button without any disabled attribute on it.
  • In line 12, we create a button with a disabled attribute on it. This becomes unusable.

Code

<html>
 <head>
 </head>
 <body>
   <div id="content">
     
     <p>button without disabled attribute:</p>
     <input type="button" value="Delete">

     <p>button with disabled attribute:</p>
       <!-- disabled attribute -->
     <input type="button" value="Delete" disabled>
   </div>
 </body>
</html>
Disable attribute in HTML

RELATED TAGS

html
communitycreator
RELATED COURSES

View all Courses

Keep Exploring