Scripsit
jjamjim@yahoo.com:
> I have a problem with styles not being inherited into form elements
> such as textarea and input.
Korpela's 1st law of CSS misunderstanding: any question containing the
word "inherit" or its derivative is based on a deep misunderstanding of
inheritance, cascade, and something else.
> <span class="myclass"><textarea>txt</textarea></span>
Why the pointless <span>, why the invalid <textarea> markup, and where's
the URL?
> So if "myclass" specifies "color:blue"
Then it's clueless. Write 100 times: blue means link. Then stop using
color: blue even in examples, since it's a _bad_ example.
> I would expect the text in the
> textarea to be blue.
That's because you don't understand inheritance.
> But it isn't - at least not in the browsers I
> have tried (firefox, opera, ie).
So what? If they have a browser style sheet that sets textarea color to
pink (or something else), textarea won't possibly _inherit_ color.
> I've had a good look
> through the css specification, but couldn't find anything about
> elements not inheriting styles.
Where did you read about elements inheriting styles?
They don't. An element _may_ inherit a value for a _property_, but only
if absolutely _no_ style sheet being applied sets that property for that
element.
> I have tried duplicating the class on the form element:
>
> <span class="myclass"><textarea class="myclass">txt</textarea></span>
What's the point of the <span>?
> That's better, but relative size properties cause problems. If
> "myclass" has font-size:200%. The textarea font would actually turn
> out 4 times the size.
Of course. When you set font size in %, you need to consider the effects
of nesting.
> So are the browsers incorrectly implementing the spec?
Yes, but that's not important right now.
> Or am I missing something.
Yes.
If you want to set the color of an element, set it, instead of setting
the color of an enclosing element.
--
Jukka K. Korpela ("Yucca")
http://www.cs.tut.fi/~jkorpela/