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?
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.
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.
contenteditable="false" Indicates that the element is not editable. contenteditable="inherit" Indicates that the element is editable if its immediate parent element is editable.
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.
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
.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With