Adam's Awesome Anecdotes

CSS Selector Precedence

Well, I was going to have a beautiful post, including code examples, of a CSS issue I encountered today and how I got around it, but apparently the support for posting code on tumblr is quite lacking.  I guess I need to sit down for a night and play with some updated CSS for my current theme maybe, but in the meantime, a very abbreviated version of what I wanted to so say is the following…

Mainly as a reminder to myself… if I use an ID attribute on an outer CSS element and apply a style to, say, all DIVs, that rule will supersede any class level selector (even if the element occurs inside the outer div) unless I explicitly define the CSS rule starting with the ID selector followed by the class selector.

So, for example, instead of just ‘.row’ (which is contained in a DIV with an ID of ‘outer’), I should use ‘#outer .div’ as my selector.


To Tumblr, Love PixelUnion

We're updating Fluid!

Soon, we'll be updating the look and feel of this theme. Read about the changes here. You can easily turn off this notification in the theme customization panel.

Close