Home > Enterprise >  How Do I Do a Read-Only Area On A Textarea In HTML?
How Do I Do a Read-Only Area On A Textarea In HTML?

Time:04-17

I am trying to create a textarea where it shows text but when you click on it and write something the text disappears. For example, on some websites is says "Search" on the textbar and when you click it and write something, the text disappears (like Google). Here is the code that i wrote:

<textarea style="resize:none;" cols="35" rows="1" wrap="virtual">Search</textarea>    

Sadly this code didnt work. It just writes some text on the textarea and it doesn't create a read-only text. I did my research and i couldn't find a question with a answer to my question. They were either not about HTML or they were about other things and not read-only. So can someone please help me with this? Thank you for your time. Have a wonderful day.

CodePudding user response:

You can use the placeholder attribute.

<textarea style="resize:none;" cols="35" rows="1" wrap="virtual" placeholder="Search"></textarea>

CodePudding user response:

You can use the placeholder attribute for that

  • Related