[whatwg] What exactly is contentEditable for?

Jorgen Horstink whatwg at jorgenhorstink.nl
Sat Sep 10 02:28:09 PDT 2005

>>imitri Glazkov wrote:
>> I was thinking more along of the lines of this:
>> <div contentEditable id="mainPageContent"> ... </div>
>> <form>
>> <input name="mainPageContentEdit" type="html" src="#mainPageContent" />
>> </form>
>Perhaps we should allow the 'form' attribute from Web Forms 2 on all 
>elements that have the 'contenteditable' attribute set.
>That would neatly solve the problem.
>Kind regards,
>  Anne van Kesteren
>  <http://annevankesteren.nl/>

the for attribute

Why don't we introduce a for-attribute to bind the content of an editing host to
a form field? One might notice it would cause problems with <label
for="some_input">Some input</label><input type="text" id="some_input">.
Just add the constraint the contentEditable attribute has to be set. I mean;
when a label element has contentEditable set true, the for attribute has lost
it original meaning.

<div contentEditable>Header</div>
<div contentEditable for="content">Content</div>
<form method="post" ...>
  <input type="hidden" id="content" name="content">

  <label for="zip">Zip code:</label><input type="text" id="zip" name="zip>
  <label contentEditable for="phone">Phone number:</label><input type="text"
id="phone" name="phone>

  <input type="submit" value="save me">

1.) the first contentEditable element has no for attribute; it's content will
not be send back to the server.

2.) the second contentEditable element binds its content to the content-input

3.) the first label element has no contentEditable attribute.

4.) the second label element has a contentEdtiable attribute. The content of the
label will be binded to the phone-input element.

The seems to me the most easy way to bind content of an editing host to a form

error handling
When it comes to binding elements one thing is for sure; the element must
When the user submits the form, the browser checks for al input elements with an
id attribute if it has a contentEditable binding. If so, the input element will
get the content of the element it binds to. (notice that elements with a for
attribute binded to an element other than input won't be submitted.)


More information about the whatwg mailing list