heretoinfinity
heretoinfinity

Reputation: 1746

HTML: what's the purpose of (difference between) text within <textarea> element compared to (and) that in the placeholder attribute?

If you can use placeholder="visible text", why would one need to have something within the <textarea> tags especially when the user has to manually delete this text? Is there any difference between the 2 code snippets below other than what I mentioned?

<textarea name="textarea" rows="10" cols="50">
Write something here</textarea>

versus

<textarea name="textarea" rows="10" cols="50" 
placeholder="Write something here">
</textarea>

The first code snippet is from: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/textarea

I saw this question[ Html placeholder text in a textarea form ] as related when typing this question but I couldn't find my answer here.

Upvotes: 1

Views: 90

Answers (2)

Ouissal
Ouissal

Reputation: 1559

You might need to have some text between the tags if the user needs to modify it.

For example, if you ask the user for their house number, road name, city and country and display that as an address in a textarea so that they can modify it and add any missing information since that would differ from a user to another.

Upvotes: 1

Quentin
Quentin

Reputation: 943569

A placeholder is a hint or example to help a user fill in the correct information. You might use it to say, for example, "Your full postal address, including the post code". Be careful not to use it as a substitute for a label element.

The content is a default value. You might use it to put the user's current address so that they can edit it to correct a mistake without having to retype the whole thing.

Upvotes: 1

Related Questions