Two things to know about IDs vs Classes. As you know, an ID can only appear once per page, while a class may repeat. The other thing is that pound for pound, a class is less “important” than an ID. (And both are more important than a bare tag name.)
If you had this construction:
<div id="foo" class="bar">
<p>Some text here</p>
</div>
And you had these styles in the page head:
#foo { color: red }
.bar { color: blue }
div { color: black }
The color inside the box would be red. The ID overrides the class, because it is more specific. Likewise, the class overrides the tag, for the same reason.
Now when you start combining selectors (the part of a CSS rule that is outside of the curly-braces) you can start becoming very very specific. If you had this:
div.bar p { color: yellow }
I think (but I’m not completely sure) that the text might become yellow. Two tags and a class combined in a single selector might be enough to overcome one ID in another selector.
The last thing to think about here is that with classes, you can stack up a bunch of them to get composite behavior. Let’s say you had this:
.foo { font-size: 36px }
.bar { color: green }
.baz { font-family: Verdana }
Now this HTML would come together as the combination of all three of those rules (big, green and Verdana):
<p class="foo bar baz">The Philly Phanatic</p>
The same thing can go for the other types of rules, except that you still can only have one ID per item, so you don’t get to stack more than one of those.
Walter
On Dec 19, 2013, at 4:42 PM, RavenManiac wrote:
Here’s a very basic un-styled responsive template I put together using a tutorial from several of Thomas Kimmich’s screencasts, which are excellent by the way. I also purchased a copy of Caleb’s outstanding Backdraft template and I’m reviewing how that works as well.
One thing I noticed is that Thomas tends to use IDs, whereas Caleb uses classes. I understand the difference between both, by I don’t see a lot of Caleb’s classes being reused, unless I’m missing something, which is very possible.
Is it better to use IDs or classes when setting up a responsive template or does it matter?
http://test.idealynx.com
offtopic mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options
offtopic mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options