views:

135

answers:

2

is it possible to make a section within a contenteditable element permanent, so that a user cannot remove it?

I have an h2 tag in a contentEditable div. I don't want the user to edit the h2 tag, so I set contentEditable=false, but the user can still select and remove it, which I want to disallow.

So, for ex:

<div contentEditable="true">
  <h2 contentEditable="false">My h2 tag</h2>
  This is a div you can edit. But you can't edit or remove the h2 tag.
</div>
A: 

Nope, sorry, it's all-or-nothin'.

A work-around would be to grab the H2 tag and reinsert it after the edit is complete, using JavaScript.

Diodeus
A: 

Why not use position:absolute to move it above the div (maybe using a proper z-index) without being inside it (in the source)?
Remember to add some padding to your div in the space allocated for your h2.

Knu