Last Updated : 22 Jul, 2022
The <textarea> placeholder attribute in HTML is used to specify the expected value to be displayed before user input in textarea element.
Syntax:
<textarea placeholder="text">
Attribute Value: This attribute contains single value text which is the initial string to be displayed before user input.
Example 1: This example uses <textarea> placeholder attribute to display the textarea placeholder description.
html
<!DOCTYPE html>
<html>
<head>
<title>
HTML Textarea placeholder Attribute
</title>
</head>
<body style = "text-align:center">
<h1 style = "color: green;">
GeeksforGeeks
</h1>
<h2>
HTML Textarea placeholder Attribute
</h2>
Description: <textarea placeholder
="Write some description here..."></textarea>
</body>
</html>
Output:
Example 2: This example uses <textarea> placeholder attribute to display the textarea placeholder description.
html
<!DOCTYPE html>
<html>
<head>
<title>HTML Textarea placeholder Attribute</title>
<style>
textarea::-webkit-input-placeholder {
color: #0bf;
}
/* Firefox 18- */
textarea:-moz-placeholder {
color: #0bf;
}
/* Firefox 19+ */
textarea::-moz-placeholder {
color: #0bf;
}
textarea:-ms-input-placeholder {
color: #0bf;
}
textarea::placeholder {
color: green;
}
</style>
</head>
<body style = "text-align:center">
<h1 style = "color: green;">
GeeksforGeeks
</h1>
<h2>
HTML Textarea placeholder Attribute
</h2>
<textarea placeholder="GeeksforGeeks is the computer"
+ " science portal for geeks."></textarea>
</body>
</html>
Output:
Supported Browsers: The browser supported by <textarea> placeholder attribute are listed below:
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4