Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is contenteditable not a style?

I was recently fiddling with contenteditable in a webpage and got irritated when I needed to set a large number of span tags with it (I ended up using JavaScript to do it). If only I could set it via CSS...

Does anyone know the rationale behind why contenteditable was designed as an attribute rather than a style?

like image 759
Vanwaril Avatar asked Apr 20 '12 08:04

Vanwaril


People also ask

What is the use of Contenteditable?

The contenteditable global attribute is an enumerated attribute indicating if the element should be editable by the user. If so, the browser modifies its widget to allow editing.

What is Contenteditable in CSS?

The contenteditable attribute specifies whether the content of an element is editable or not. Note: When the contenteditable attribute is not set on an element, the element will inherit it from its parent.

What is false about Contenteditable attribute?

contenteditable="false" Indicates that the element is not editable. contenteditable="inherit" Indicates that the element is editable if its immediate parent element is editable.

What is Contenteditable true?

The contenteditable is used to specify whether the element's content is editable by the user or not. Syntax: <element contenteditable="true|false"> This attribute has two values. true: If the value of the contenteditable attribute is set to true then the element is editable.


2 Answers

Most people would argue that contentEditable defines behaviour, rather than style (which is true).

WebKit has a CSS property that is similar to contentEditable: -webkit-user-modify.

like image 135
Andy E Avatar answered Sep 29 '22 12:09

Andy E


try

span {     -webkit-user-modify: read-write;     -moz-user-modify: read-write;     user-modify: read-write; } 

it worked on Firefox, Chrome. You can find more info about user-modify

like image 28
crazyjune Avatar answered Sep 29 '22 12:09

crazyjune