I know about how to stylize the placeholder from here css tricks
But I need to know about how to apply to a specific text area.My text-area has class "message".
Thanks.
Actually I used padding.But was interested about thee styling of placeholder with a css3 seelctor.
any help?
Just add padding to the input like this: . tbsearchbar { padding-top: 10px; color: red; //To add some color. }
The placeholder attribute of the <textarea> element is used to set a placeholder text in the textarea. A placeholder is considered as a hint, like “Enter you name”, “Enter mobile number”, “Write in 100 words”, etc. Above, text is the hint you want to set for the textarea as a placeholder text.
The ::placeholder selector selects form elements with placeholder text, and let you style the placeholder text. The placeholder text is set with the placeholder attribute, which specifies a hint that describes the expected value of an input field.
All you need is .message { padding-top: 10px; }
to achieve the result you're after.
It will apply to any <textarea>
that has the class of message
EDIT
If you don't want to apply padding to the element, try this instead. It literally just targets the placeholder
.
.message::-webkit-input-placeholder {
padding-top: 10px;
}
.message::-moz-input-placeholder {
padding-top: 10px;
}
.message:-moz-input-placeholder {
padding-top: 10px;
}
.message:-ms-input-placeholder {
padding-top: 10px;
}
Can be seen in action here, I set up 2 <textarea>
's to show this - http://jsfiddle.net/andyjh07/tan7k4rf/
This what you are looking for?
<textarea placeholder="Placeholder text!" class="message"></textarea>
<textarea placeholder="Placeholder text!" ></textarea>
.message::-webkit-input-placeholder {padding-top: 10px;}
.message:-moz-placeholder { /* Firefox 18- */padding-top: 10px;}
.message::-moz-placeholder { /* Firefox 19+ */padding-top: 10px;}
.message:-ms-input-placeholder {padding-top: 10px;}
http://jsfiddle.net/92gnt7qt/3/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With