Open In App
Related Articles

How to specify an input field is read-only in HTML ?

Improve
Improve
Improve
Like Article
Like
Save Article
Save
Report issue
Report

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:


Last Updated : 25 Dec, 2020
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads