Closed Bug 73429 Opened 25 years ago Closed 25 years ago

<a> tags not inheriting styles

Categories

(Core :: CSS Parsing and Computation, defect)

Sun
Solaris
defect
Not set
normal

Tracking

()

VERIFIED INVALID

People

(Reporter: gtr, Assigned: pierre)

Details

From Bugzilla Helper: User-Agent: Mozilla/5.0 (X11; U; SunOS 5.8 sun4u; en-US; 0.8.1) Gecko/20010311 BuildID: 2001031121 The <a> tags don't seem to inherit style classes from their parent elements. If I have a class .red that sets the link colors to red, and if I apply this to a <div>, then the colours don't propagate from <div> through <p> to <a>. Reproducible: Always Steps to Reproduce: Have mozilla render this document: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/1999/REC-html401-19991224/strict.dtd"> <html> <head> <style type="text/css"> .red {color: red} a.red:link {color: red} a.red:visited {color: black} a.red:hover {color: yellow} </style> <title>Possible bug in Mozilla</title> </head> <body> <div class="red"> <h1>Red heading?</h1> <p> This paragraph should be in red too. <a href="http://www.ast.cam.ac.uk" class="red">So should this link.</a> </p> </div> </body> Then add class="red" to the <a> tag and try again. Actual Results: Without the class="red", the link is rendered in the default colours. With the class="red", the link gets the CSS colours. Expected Results: The link should take the CSS colours without needing to be marked up explictly as class="red". That is, the paragraph should inherit the styles from the <div> and the <a> should inherit them from the paragraph. The test document passes the W3C validator.
Status: UNCONFIRMED → RESOLVED
Closed: 25 years ago
Resolution: --- → INVALID
This seems to be correct behavior to me.... Classes are _not_ inherited in CSS. The only reason things inside the <div> inherit its color is because the default value of "color" is "inherit". So in this case. The <div> has a style of { color:red } applied to it. The <a> has a style applied to it as well, by the UA stylesheet. Since the UA style sets the <a> color to something other than "inherit", the <div>'s color is not inherited. From http://www.w3.org/TR/REC-CSS2/cascade.html#cascade : "User agent: Conforming user agents must apply a default style sheet (or behave as if they did) prior to all other style sheets for a document. A user agent's default style sheet should present the elements of the document language in way that satisfy general presentation expectations for the document language (e.g., for visual browsers, the EM element in HTML is presented using an italic font)." This is the style sheet that sets the "underlined and whatever color the user set for links" style for <a> The W3C validator only catches syntax errors, not logic errors, by the way. In this case, your syntax is perfectly correct.... Marking invalid -- this is the expected behavior per the CSS spec in these circumstances.
I concur with bz. I'll leave it to Ian for verification and cc myself just in case he spots something we didn't.
Yep, that's right...
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.