W3C home > Mailing lists > Public > whatwg@whatwg.org > September 2012

Re: [whatwg] Should editable elements have placeholder attribute?

From: David Young <dyoung@pobox.com>
Date: Fri, 31 Aug 2012 20:22:07 -0500
To: whatwg@lists.whatwg.org
Message-ID: <20120901012207.GW456@pixotech.com>
On Thu, Aug 30, 2012 at 11:44:46AM +0300, Jussi Kalliokoski wrote:
> On Thu, Aug 30, 2012 at 11:43 AM, Jussi Kalliokoski <
> jussi.kalliokoski@gmail.com> wrote:
> 
> > It's pretty simple to make a naive placeholder for contenteditable
> > elements with CSS:
> >
> > [contenteditable]:not(:focus):empty::after {
> >         content: attr(data-placeholder);
> >         color: #ccc;
> > }
> >
> > I call it a bit naive because it turns out that if you have insert a line
> > break in the box, there will always be one line break inside the element
> > (even if you clean it empty), making the element non-empty and hence the
> > placeholder won't show.
> >
> > You can try it in action here:
> > file:///home/jussi/code/contenteditable/index.html
> >
> 
> Whoooops, yeah, I'm pretty sure that won't work, try this instead:
> http://labs.avd.io/contenteditable/

This demonstrates some unexpected contenteditable results on
Chrome 21.0.1180.82 under Mac OS X.  I cannot seem to return the
contenteditable to the empty state again---i.e., to the state where the
placeholder shows---using Chrome.  All that I have entered is a space.
Backspacing over the space leaves a <br>.  Inserting a space again
deletes the <br>.

In Firefox 3.6.19 it is necessary to insert two spaces before a <br>
appears; the <br> cannot be deleted, not even by inserting a space. :-)

Dave

-- 
David Young
dyoung@pobox.com    Urbana, IL    (217) 721-9981
Received on Saturday, 1 September 2012 01:22:35 UTC

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 16:59:45 UTC