{"id":166069,"date":"2014-03-17T12:40:34","date_gmt":"2014-03-17T19:40:34","guid":{"rendered":"http:\/\/css-tricks.com\/?page_id=166069"},"modified":"2021-08-04T10:25:53","modified_gmt":"2021-08-04T17:25:53","slug":"read-write-read","status":"publish","type":"page","link":"https:\/\/css-tricks.com\/almanac\/selectors\/r\/read-write-read\/","title":{"rendered":":read-write \/ :read-only"},"content":{"rendered":"\n
The According to the official CSS Specifications, a :read-write<\/code> and
:read-only<\/code> selectors are two mutability pseudo-classes aiming at making form styling easier based on
disabled<\/code>,
readonly<\/code> and
contenteditable<\/code> HTML Attributes. While the browser support is not that bad, the various implementations are quite wonky.<\/p>\n\n\n\n
:read-write<\/code> selector will match an element when:<\/p>\n\n\n\n
input<\/code> which has
readonly<\/code> nor
disabled<\/code> attributes.<\/li>
textarea<\/code> which has neither
readonly<\/code> nor
disabled<\/code>\n<\/li>
contenteditable<\/code> attribute)<\/li><\/ul>\n\n\n
Syntax & Example<\/h3>\n\n\n
\/* Any element that is not writable *\/\n:read-only { }\n\n\/* ... so you might want to scope it *\/\ninput:read-only, \ntextarea:read-only,\n[contenteditable]:read-only {\n cursor: not-allowed;\n}\n\n\/* Any enabled text input \n or enabled textarea \n or element with the contenteditable attribute *\/\n:read-write {\n background: white;\n cursor: text;\n}<\/code><\/pre>\n\n\n
Browser support<\/h3>\n\n