Skip to content

Instantly share code, notes, and snippets.

@emolr
Created May 12, 2015 08:00
Show Gist options
  • Save emolr/0ff3481c9a59014abf45 to your computer and use it in GitHub Desktop.
Save emolr/0ff3481c9a59014abf45 to your computer and use it in GitHub Desktop.
/*
* Contenteditable placeholder
* -----------------------------------
* Emulates the behavior of the standerd implementation
* of the input placeholder="text", but can be used on any
* html element that supports focus.
* http://stackoverflow.com/questions/1599660/which-html-elements-can-receive-focus
*/
[contenteditable="true"]:before {
content:attr(placeholder);
pointer-events: none;
}
[contenteditable="true"]:not(:empty):before{
display: none;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment