HTML input readonly Attribute

Last Updated : 25 May, 2026

The readonly attribute is used to make an input field non-editable while still allowing users to view and select its value. The field value is also submitted with the form.

  • Prevents users from modifying the input value.
  • The input field can still be focused and its value can be selected.
  • Unlike disabled fields, readonly inputs are included in form submission.

Syntax:

<input readonly>

Example: This example uses HTML <input> readonly Attribute. 

html
<!--Driver Code Starts-->

<!DOCTYPE html> 
<html> 

<head> 
    <title>HTML Input readonly Attribute</title> 
</head> 

<!--Driver Code Ends-->

<body style = "text-align:center">     
    <h1 style = "color: green;">
        GeeksforGeeks
    </h1> 
        
    <h2>
        HTML Input readonly Attribute
    </h2> 

    <label>Input: 
    
        <!--A readonly input-->
        <input type="text" name="value" value = 
            "This input field is readonly" readonly> 
    </label> 
</body> 

<!--Driver Code Starts-->

</html>                    

<!--Driver Code Ends-->
Comment