The readonly attribute of the <textarea> element is used to set a textarea as readonly. The visitor cannot change the text in the textarea if it is set as readonly.
However, visitor can copy that content.
Following is the syntax −
<textarea readonly>
Let us now see an example to implement the readonly attribute of the <textarea> element −
Example
<!DOCTYPE html> <html> <body> <h2>Interview Questions</h2> <p>Q1</p> <textarea rows="6" cols="70" placeholder="Why do you want go for the Editor Job Profile? (100 words)"> </textarea> <p>Q2</p> <textarea rows="6" cols="70" placeholder="Do you have any previous publishing experience? (100 words)"> </textarea> <p>Guidelines to appear for interview:</p> <textarea rows="6" cols="70" readonly> The interviewee should reach at 10AM with the certificates. </textarea> </body> </html>
Output
In the above example, we have 3 textarea −
<p>Q1</p> <textarea rows="6" cols="70" placeholder="Why do you want go for the Editor Job Profile? (100 words)"> </textarea> <p>Q2</p> <textarea rows="6" cols="70" placeholder="Do you have any previous publishing experience? (100 words)"> </textarea> <p>Guidelines to appear for interview:</p> <textarea rows="6" cols="70" readonly> The interviewee should reach at 10AM with the certificates. </textarea>
One of this textarea is set as readonly, therefore users won’t be able to add any text in it −
<textarea rows="6" cols="70" readonly> The interviewee should reach at 10AM with the certificates. </textarea>