The easiest option is to use the attribute placeholder:
<input type="text" placeholder="At least one tag, such as 'html', 'asp.net', max five tags." />
JS Fiddle demo .
If cross-compatibility is a requirement, then JavaScript is also an option:
var inputs = document.getElementsByTagName('input');
for (i=0; i<inputs.length; i++){
if (inputs[i].hasAttribute('data-hint')){
inputs[i].value = inputs[i].getAttribute('data-hint');
inputs[i].style.color = '#999';
inputs[i].onclick = function(){
this.value = '';
};
inputs[i].onblur = function(){
if (this.value == '' || this.value == this.getAttribute('data-hint')){
this.value = this.getAttribute('data-hint');
this.style.color = '#000';
}
};
}
}
JS Fiddle demo .
jQuery:
$('input:text').each(
function(){
$(this).val($(this).attr('data-hint'));
$(this).css('color','#999');
}).click(
function(){
$(this).val('');
$(this).css('color','#000');
}).blur(
function(){
if ($(this).val() == ''){
$(this).val($(this).attr('data-hint'));
$(this).css('color','#999');
}
});
JS Fiddle demo.
:
JavaScript:
JQuery