Since ages we are using <LABEL> for labelling our form fields, our input fields. But very few of us use placeholder attribute to label the fields. Instead of using <LABEL>, its better to use "placeholder". We can use any text in that attribute and that particular text will appear in that input field.
Default color of the placeholder text is light grey in color. Although all browsers doesnt support this, but in the browsers implementing it so far shows light grey text. Its nice to have the default color but there are situations when your design doesnt support this. This default color doesnt go with the look and feel of your design. In those cases you have to look for styling the placeholder text. Here's the solution.
Use following CSS:
::-webkit-input-placeholder {
color: #999;
}
:-moz-placeholder {
color: #999;
}
::-moz-placeholder {
color: #999;
}
:-ms-input-placeholder {
color: #999;
}
Result
Thanks for visiting.
Share Your Solutions
HTML:
<input type="text" name="name" placeholder="Your Name"/>
Result
Result
Default color of the placeholder text is light grey in color. Although all browsers doesnt support this, but in the browsers implementing it so far shows light grey text. Its nice to have the default color but there are situations when your design doesnt support this. This default color doesnt go with the look and feel of your design. In those cases you have to look for styling the placeholder text. Here's the solution.
Use following CSS:
::-webkit-input-placeholder {
color: #999;
}
:-moz-placeholder {
color: #999;
}
::-moz-placeholder {
color: #999;
}
:-ms-input-placeholder {
color: #999;
}
HTML
<input type="text" name="name" id="nameBox" placeholder="Your Name"/>
CSS:
#nameBox::-webkit-input-placeholder{ color: #FF0000; }
#nameBox::-moz-placeholder{ color: #FF0000; }
#nameBox:-moz-placeholder{ color: #FF0000; }
#nameBox:-ms-input-placeholder{ color: #FF0000; }
Result
Thanks for visiting.
Share Your Solutions
Thanks for the awesome tip :)
ReplyDeleteMost welcome Friend, keep visiting for more solutions
Delete