HTML5 textarea placeholder not appearing

后端 未结 9 1824
佛祖请我去吃肉
佛祖请我去吃肉 2020-11-29 16:02

I cannot figure out what is wrong with my markup, but the placeholder for the text area will not appear. It seems as though it may be covered up with some blank spaces and t

相关标签:
9条回答
  • 2020-11-29 16:45

    I had the same issue, only using a .pug file (similar to .jade). I realized that it was also a space issue, following the end of my closing parentheses. In my example, you need to highlight the text after (placeholder="YOUR MESSAGE") to see:

    BEFORE:

    form.form-horizontal(method='POST')
      .form-group
        textarea.form-control(placeholder="YOUR MESSAGE") 
      .form-group  
        button.btn.btn-primary(type='submit') SUBMIT
    

    AFTER:

    form.form-horizontal(method='POST')
      .form-group
        textarea.form-control(placeholder="YOUR MESSAGE")
      .form-group  
        button.btn.btn-primary(type='submit') SUBMIT
    
    0 讨论(0)
  • 2020-11-29 16:49

    Delete all spaces and line breaks between <textarea> opening and closing </textarea> tags.

    <textarea placeholder="YOUR TEXT"></textarea>  ///Correct one
    
    <textarea placeholder="YOUR TEXT"> </textarea>  ///Bad one It's treats as a value so browser won't display the Placeholder value
    
    <textarea placeholder="YOUR TEXT"> 
    </textarea>  ///Bad one 
    
    0 讨论(0)
  • 2020-11-29 16:49

    Between the opening and closing tag in our case textarea tag shouldn't be space or newline character or any text(value).

    If there's space, newline character or any text, it's considered as value which overrides placeholder.

        **PlaceHolder Appears**
        <textarea placeholder="Am Default Message"></textarea>
    
        **PlaceHolder Doesn't Appear**
    
        <textarea placeholder="Am Default Message">  </textarea>
       <textarea placeholder="Am Default Message"> 
       </textarea>
       <textarea placeholder="Am Default Message">Something</textarea>
    
    0 讨论(0)
提交回复
热议问题