In this tutorial, you will learn how to make input field disabled in HTML. When you are creating a form, you may want to disable some of the input elements.
To make the input field disabled, we have to use the
disabled attribute. The disabled attribute is a Boolean attribute. The disabled attribute is used to specify that the input element should be disabled so that a user could not enter any value in it.
In the following example, we will make an input field disabled. Please have a look over the code example and the steps given below.
- In the HTML file, we have 2 elements (
label element is used to specify a label for an input field. The value of
for attribute is set to the email of the corresponding input field.
- The input element specifies an input field where the user can enter data.
- The input has a
type attribute with a value of the text, a
name attribute with the value of email, and an
id attribute with a value of email. The
disabled attribute specifies that the input element is disabled.
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>input field disabled</title>
<input type="text" name="email" id="email" disabled>