0

I have a textarea inside a div. The div css sets the color, but the textarea doesn't seem to react to that.

Is this the correct behavior ? how can I get the color property to apply from the div to the textarea ?

here is an example

.c1 {
  color: red;
}
<div class="c1">
  An now for something completly different :<br/>
  <textarea>
          the news : spam spam spam spam spam
        </textarea>
</div>
j08691
  • 204,283
  • 31
  • 260
  • 272
user3617487
  • 155
  • 11

5 Answers5

1

Textarea will not inherit until you mark it so

.c1 textarea{
    color:inherit;
}

So you can apply color for both div child and textarea fields. If I am not mistaking input tag also does not inherit color by default

Void Spirit
  • 879
  • 6
  • 18
1

It's because textarea has default style applied by the browser so the inheritance will not work:

enter image description here

enter image description here

You need to specify a color for the textarea or use inherit to get the color of the div

.c1 {
  color: red;
}
textarea {
 color:inherit;
}
<div class="c1">
  An now for something completly different :<br/>
  <textarea>
          the news : spam spam spam spam spam
        </textarea>
</div>
Temani Afif
  • 245,468
  • 26
  • 309
  • 415
0

Please try below CSS.

.c1,textarea.classname {color:red;}
stalinrajindian
  • 1,363
  • 1
  • 14
  • 22
0

Try this CSS Code

.c1,textarea {  
    color:red;  
}
Suresh Kumar Ariya
  • 9,516
  • 1
  • 18
  • 27
Akil Makda
  • 373
  • 1
  • 3
  • 9
0

Browsers gives default styles to inputs, buttons,... So Textarea have color:initial set. You need to specify in your code the color for Textarea.

.c1,
textarea{
  color:red;
}
aflyzer
  • 563
  • 3
  • 12