Search code examples
htmlcssplaceholder

How to adjust the alignment of placeholder text in input box?


enter image description here

The placeholder text in the third box appears in the middle while i want to be at the top. HTML

<div id="message">
    <ul>
      <li><h1>Send us a message</h1></li>
      <li><input type="text" placeholder="Name"></li>
      <li><input type="text" placeholder="Email"></li>
      <li><input type="text" style="height:150px;" placeholder="Message"></li>
      <li><a href="#">Send</a></li>
    </ul>
</div>

Here is JSFiddle


Solution

  • If you're wanting a multi-line input field you should use the textarea element.

    <li>
        <textarea placeholder="Message"></textarea>
    </li>
    

    You can then style this however you like using the textarea selector:

    #message input,
    #message textarea {
        width: 250px;
        height: 40px;
        padding: 10px;
    }
    
    #message li input[type=text],
    #message li textarea {
        border-radius: 5px;
        -webkit-border-radius: 5px;
        -moz-border-radius: 5px;
        border: none;
    }
    
    #message li textarea {
        height: 150px;
        resize: none;
    }
    

    JSFiddle demo.