html - Placeholder text in an input field with CSS only (no JavaScript) -


instead of labeling each field in form, preferable (from design standpoint) have placeholder text in each field. example, instead of having this:

 ---------------------------------- full name: | | ---------------------------------- 

you have this:

 ---------------------------------- | full name | ---------------------------------- 

the when click in field, text disappears , can write whatever want. if skip on field without entering text, placeholder reappears.

i've seen done many ways, methods involve javascript. example, twitter decent job on signup page if javascript disabled end typing name on word 'full name'.

i'm looking css-only method work javascript disabled. potential solution i've come set background of <input> tag image of desired text , use input:focus pseudo-class clear background image when clicks on text box. seems work nice not have use images.

does know of resource on how this?

this preferred method, , works in current browsers:

<input type="text" name="" placeholder="full name"/> 

this version works ie9 , before:

<input type="text" name="" value="full name" onfocus="value=''" onblur="value='full name'"/> 

Comments

Popular posts from this blog

javascript - backbone.js Collection.add() doesn't `construct` (`initialize`) an object -

php - Get uncommon values from two or more arrays -

Adding duplicate array rows in Php -