How to set that the specified element/group of elements should be disabled in HTML?


Use the disabled attribute to disable an element. The attribute can be used for the following elements: <button>, <input>, <select>, <textarea>, etc.

Example

You can try to run the following code to implement disabled attribute −

<!DOCTYPE html>
<html>
   <body>
      <p>Which sports do you like?</p>
      <form action = "" method = "get">
         <input type = "checkbox" name = "vehicle" value = "football" checked> Football<br>
         <input type = "checkbox" name = "vehicle" value = "cricket" checked> Cricket<br>
         <input type = "checkbox" name = "vehicle" value = "hockey"> Hockey<br>
         <input type = "submit" value = "Submit" disabled>
      </form>
   </body>
</html>

Updated on: 24-Jun-2020

65 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements