HTML | <textarea> placeholder Attribute

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.

filter_none

edit
close

play_arrow

link
brightness_4
code

<!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>                    

chevron_right


Output:
textareaplaceholder

Example 2: This example uses <textarea> placeholder attribute to display the textarea placeholder description.

filter_none

edit
close

play_arrow

link
brightness_4
code

<!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>                    

chevron_right


Output:
textareaplaceholder

Supported Browsers: The browser supported by <textarea> placeholder attribute are listed below:

  • Apple Safari 5.0
  • Google Chrome
  • Firefox 4.0
  • Opera 11.5
  • Internet Explorer 10.0


My Personal Notes arrow_drop_up


If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.




Article Tags :
Practice Tags :


Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.