How to disable an input tag using HTML?

March 13, 2021 - 1 min read

To disable an input field, you can pass an attribute called disabled to the tag in HTML.

<!-- Disable `Input` Tag in HTML -->
<input type="text" disabled />
  • Adding the disabled attribute to the input tag will restrict the user to enter text or content to the input and will have a grayed-out color unless you specify a color for the disabled state in CSS.

For example, let's set a value in the input tag using the value attribute and then disable the input tag.

<input type="text" value="I'm a value which can only be copied" disabled />

That's all! 😃

See the above code live in JSBin

Feel free to share if you found this useful 😃.