1

I want to disable textarea under certain class using css ONLY . I don't want to use Javascript.

<div class='commentArea'>
    <textarea> I want do disable this using CSS </textarea>
</div>

How to set the attribute readonly to textarea ? or is there any other way to make textarea non-editable using CSS ?

Sohan Soni
  • 1,207
  • 21
  • 35
  • accepted answer from above link does not work anymore i.e. i tried setting .print { -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; -o-user-select: none; user-select: none; } but its not working – Sohan Soni Jul 20 '15 at 09:57
  • guys i have gone through lot of links already, and I did not get any good answer yet,and so I asked this question. Please do not direct me to another link where there is no solution. – Sohan Soni Jul 20 '15 at 09:58
  • 2
    The accepted answer states that many browsers don't support the styles provided. Other than that, there is no solution. – George Jul 20 '15 at 10:01
  • 1
    CSS doesn't manipulate HTML attributes. Since the data you need to set must be an HTML attribute, you're stuck up a creek without a paddle. You must use JS for this task. You'll have no more luck trying perform open-heart surgery on a giraffe using a dolphin, than you'll have trying to set an html attribute using css. Some things just aren't possible, regardless of how advantageous they could be. – enhzflep Jul 20 '15 at 10:05

2 Answers2

-2
<div class='commentArea'>
   <textarea readonly> I want do disable this using CSS </textarea>
</div>
Nageshwari P
  • 35
  • 1
  • 7
  • **Sohan Soni** asked solution for either css/html – Nageshwari P Jul 20 '15 at 10:40
  • 1
    No, they said "set readonly attribute to true using CSS" and "I want do disable this using CSS" and "I want to disable textarea under certain class using css ONLY" and "is there any other way to make textarea non-editable using CSS" – Quentin Jul 20 '15 at 10:50
  • he wants to set read-only by using CSS but not HTML. – Milo Chen Aug 29 '21 at 13:45
-2

You can use 'pointer-events' css property as given below.

.commentArea textarea{
    pointer-events: none;
}

Note : This property might not work in older browsers.

obuliraj
  • 106
  • 7