Ruby on Rails Tuesday, May 31, 2011

On May 31, 2011, at 6:32 PM, Bill Walton wrote:

> I believe most current browsers
> will give precedence to the stylesheet over inline styling.

Sorry, I disagree with this. The stylesheet is given the same priority
as ever, in keeping with the idea of "weight" inherent to the cascade.
The closer a declaration is to the thing that it governs, the more
authoritative it is taken to be.

You can see this very easily in Safari's Web Inspector by using
(Contextual Menu: Inspect Element) and look at the attributes declared
on the local object versus those in the style sheet(s). The list in
the sidebar will show various attributes grayed back and crossed out
as those higher in the list contradict them. At the very top of the
list is the Computed Style section (closed by default) which will show
the result of all this cascading jujutsu.

If you make a little sample document, you can see this for yourself.
Local (inline) attributes still trump all.

The only exception to this would be if you add the !important flag to
the end of a rule. That will override even a locally-declared
attribute, and didn't use to, and this may be the part you're
remembering.

Walter

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

No comments:

Post a Comment