Skip to content
Related Articles

Related Articles

Improve Article
How to specify an input field is read-only in HTML ?
  • Last Updated : 25 Dec, 2020

In this article, we will specify an input field is read-only in HTML. The readonly attribute of <input> element is used to specify that the input field is read-only. If an input is readonly, then it’s content cannot be changed but can be copied and highlighted. It is a boolean attribute.

Syntax:

<input readonly>

Example: This example using <input> readonly attribute to set the read-only value.

HTML




<!DOCTYPE html>
<html>
  
<head>
    <title>
        How to specify an input
        field is read-only in HTML?
    </title>
</head>
  
<body style="text-align:center">
    <h1 style="color: green;">
        GeeksforGeeks
    </h1>
  
    <h2>
        How to specify an input
        field is read-only in HTML?
    </h2>
  
    <label>Input Value:
  
        <!--A readonly input-->
        <input type="text" name="value" 
            value="This input field is readonly"
            readonly>
    </label>
</body>
  
</html>

Output:

My Personal Notes arrow_drop_up
Recommended Articles
Page :