I have a textarea and a stylesheet that specifies, for the textarea's ID, "border: 1px solid black !important;" and I have tried a couple of variants. (The stylesheet that specifies this is the last invoked.) There is at least one other style that would apply, but none of the other ones specify !important, and the textarea does not have any inline styles Chrome recognizes.

The textarea in question, elsewhere given styles without !important, displays 1px solid black borders for two sides in Chrome and no sides that are styled in the requested manner in IE and Firefox. In Chrome, if I uncheck the other stylesheet's border specification, the 1px solid black border appears and is apparently unshadowed.

This suggests there is something I don't understand about precedence in CSS, because I would expect !important, in the last imported style sheet and in the absence of inline styles, to be a trump card on at least one level. But it is apparently being overruled, by earlier styles specified without !important.

What can I do with my textarea, and more importantly, what do I fail to understand about setting a last word in CSS styling?

  • do you have a reset stylesheet that specifies border:none for textareas? Tony B about 6 years ago
  • I just reworded part of my question. The textareas have borders for some sides, as per other stylesheets apparently. But they are not styled like I requested, e.g. a 2px solid silver border. That much is specified in the stylesheet; I just don't understand why something that's not !important is winning over something that is. Jonathan Hayward about 6 years ago
  • There is a reset that specifies border: 0 for textareas, but without !important, and before I started working textareas did have some borders, just not yet 1px solid black. Jonathan Hayward about 6 years ago

1 answer

0
points

I found a way to appease the problem at least, although I'd hesitate to say this is really a solution.

The existing style that was trumping things appeared in:

div.className textarea

I had been making changes to

textarea#name

I changed the rule to apply to:

div.className textarea,
textarea#name

And now it's styled the way I was aiming for.

Answered about 6 years ago by Jonathan Hayward