2

chrome supports the isContentEditable property (lists it in the "Inspect Element"), but reports false for INPUT, FORM - actually, everything.

too me, for example, seems that INPUT, non-readonly, should be true.

does anybody know what's going on?

cc young
  • 18,939
  • 31
  • 90
  • 148
  • [What](http://blog.whatwg.org/the-road-to-html-5-contenteditable) [is](http://html5demos.com/contenteditable) [`isContentEditable`](http://www.w3.org/TR/html5/editing.html#contenteditable)? – Alex Sep 21 '11 at 09:44

2 Answers2

10

isContentEditable doesn't have anything to do with forms and input boxes. It was designed to be a way to flag inline editable html content.

You can see a working example here: http://www.navioo.com/javascript/dhtml/isContentEditable_Example_4513.html

You can read about it

here: http://www.w3.org/TR/2009/WD-html5-20090423/editing.html

or: http://blog.whatwg.org/the-road-to-html-5-contenteditable

icchanobot
  • 3,323
  • 27
  • 37
  • thanks! two questions: one, do you know of a link on how to use contentEditable, eg, how do you know if a user entered a change, and two, is there a single attribute to know if a normal HTMLElement is enterable, eg, INPUT? – cc young Sep 21 '11 at 09:58
  • 1) im pretty sure it is not commonly used because it doesn't have standard events thrown like onEdited or anything. You can find some answers here: http://stackoverflow.com/questions/1391278/contenteditable-change-events – icchanobot Sep 21 '11 at 10:02
  • 2) Cant you can just check if its an input or a textarea? is anything else "enterable"? – icchanobot Sep 21 '11 at 10:03
  • 1) thanks, 2) input, textarea (not readonly), checkbox, radio, and new HTML5 types and widgets - was after safe and a little future-proof – cc young Sep 21 '11 at 10:13
  • checkboxes, radio buttons and the new html5 types are all `input` tags. only `textarea` and `select` aren't i think. – icchanobot Sep 21 '11 at 10:17
  • `contenteditable` is very widely used. Nearly all web-based WYSIWYG editors such as TinyMCE and CKEditor use it, for example. You're right that event support isn't great, though hopefully the HTML5 `input` event will make it into contenteditable elements soon. – Tim Down Sep 21 '11 at 11:32
3

An element's isContentEditable property, in browsers which support it, tells you whether the immediate child content of the element is editable. It applies specifically to regular non-interactive content (i.e. not form controls), which can be made editable using the contenteditable attribute:

<div contenteditable="true">This text is all <i>editable</i></div>

The isContentEditable property of both the <div> and the <i> elements above will report true. However, be aware that not every browser that supports contentEditable also supports isContentEditable: Firefox 3.x, for example, supports contentEditable but not isContentEditable.

contenteditable is standardized in HTML5 but has been around for over a decade. It was first introduced in IE 5.5 in 2000 and eventually made its way into other browsers several years later. Firefox has had it since version 3.0 (although it had the document-wide equivalent designMode since pre-1.0) and Safari since (I think) 2.0.

Here's a good summary of the history of contentEditable: http://blog.whatwg.org/the-road-to-html-5-contenteditable

Tim Down
  • 318,141
  • 75
  • 454
  • 536
  • thanks. @icchanobot pointed out the site and purpose - never knew any of that existed! sounds very nice - as one comment said, "goodbye textarea" - now researching how to use and how well supported - for example, caniuse.com does not list it, and some comments saying Safari for phone does not support. – cc young Sep 21 '11 at 10:39
  • @cc: Oh yes, I hadn't spotted I'd duplicated @icchanobot's link. `contenteditable` isn't supported in Safari in iOS yet, but will be in iOS 5. – Tim Down Sep 21 '11 at 11:30