The contenteditable HTML Attribute


Who needs form fields? Now that we have the contenteditable attribute, any element can be editable. Here’s all you have to do to make a field editable:

<div contenteditable>This is editable content. Go ahead, change it.</div>

Which acts just like this area (click the text to edit it):

This is editable content. Go ahead, change it.

Pretty cool, right? Remember though, you’re not in a form, so you’ll need to submit changes with ajax, or save them locally in the browser (Local Storage, anyone?). Either way, this is pretty nice.

I also heard a rumor that in HTML6 they’ll include the contentedible attribute, so you’ll be able to eat elements with ease.


Leave a Reply

Your email address will not be published. Required fields are marked *