Forum Moderators: not2easy
wouldn't an inline style attribute overide a css style?
small little example:
<html>
<head>
<title>Untitled</title>
<style type="text/css">
#foo #bar{display:none;}
#foo span.bar{color:#0f0;}
</style>
</head>
<body>
<div id="foo">
<ol id="bar" style="display:block">
<li>one</li>
<li>two</li>
</ol>
<span class="bar" style="color:#00F">i should be blue</span>
</div>
nothing
</body>
</html>
from: [w3.org...]
In HTML, values of an element's "style" attribute are style sheet rules. These rules have no selectors, but for the purpose of step 3 of the cascade algorithm, they are considered to have an ID selector (specificity: a=1, b=0, c=0). For the purpose of step 4, they are considered to be after all other rules.
Maybe I am reading this wrong but wouldn't this mean that style should override all other css (not including the use of!important) and the ol should be displayed?
so is opera saying the 2 ID's is more important than a "style" attribute (which may equate to only 1 ID in opera-- I don't know just guessing)
It behaves as I expect on Netscape7.1, firefox0.8, safari, ie6
tia
[edited by: SuzyUK at 12:13 pm (utc) on Aug. 21, 2004]
[edit reason] linked URL [/edit]
I would say they are correct just ever so picky ;)
From the same link you provided
A selector's specificity is calculated as follows:
- count the number of ID attributes in the selector (= a)
- count the number of other attributes and pseudo-classes in the selector (= b)
- count the number of element names in the selector (= c)
- ignore pseudo-elements.
this gives the selector in your stylesheet #foo #bar{display:none;} a specificity number of 200 (per the 2 x ID attributes used in the selector)
Then the rules as applied to inline styles
These rules have no selectors, but for the purpose of step 3 of the cascade algorithm, they are considered to have an ID selector (specificity: a=1, b=0, c=0).
if you change the rule in the stylesheet to #bar{display:none;} then it has a specificity of 100 too and it will be overridden by the inline style with the same specificity as expected because it's later in the cascade.
so is opera saying the 2 ID's is more important than a "style" attribute
Suzy