In order to disable a textarea (or any other input element), you can:
In HTML, you can write:
<textarea id='mytextarea' disabled></textarea>
From jQuery, you can:
$("#mytextarea").attr("disabled","disabled");
CSS? Is it possible to disable the textarea with CSS?
No, it cannot be done in CSS. But, you can style the input as "disabled" in CSS and use the property maxlength="0" in the HTML code so people won't be able to write in it. Also, be sure to change the pointer style as the right one so people won't see the pointer that tell them to write in the box.
CSS deals with styles. Disabling an element is functional.
Of course, CSS is becoming more functional with things like transitions and that's more of a grey area. But the purpose of CSS is to keep it as styles and not to control element functional control.
No, css cannot disable elements.
You can "fake" a disabled control styling it to visually look disabled.
Not possible in pure CSS unfortunately... you'd have to use Javascript.
You can make elements completely unclickable with css:
point-events: none;
In a Project I have a container with a textarea and some buttons inside. To disable the whole thing I append a class to it with the following code:
While the opacity is only for the show, the :after element is doing the work. All elements in the container are no longer reacting to click and mouseover (reaching them with the tabulator will still work though). For my needs and in my case this works fine and is an easy css hack.
You can make a textarea appear disabled, but you can't actually disable it.
Using JavaScript, all you're really doing is modifying the same DOM attribute that's set by the HTML
disabled
attribute, so using HTML and JavaScript you're essentially doing the same thing. CSS, however, is completely out of this picture, as it doesn't do DOM manipulation of any sort — all it controls is the appearance (visual or otherwise) of an element, not its behavior.