Forums | Lich King Guides | Raid Movie Guides | Blogs
On CSS Polymorphism (not about WoW at all)
TankSpot // Blogs // Protcore!
Rate this Entry

On CSS Polymorphism (not about WoW at all)

Posted 11-07-2008 at 10:19 AM by Thireas
Updated 11-07-2008 at 03:22 PM by Thireas
As the title says, this isn't about WoW or tanking at all. I'm a web developer by trade, and I've been running into this issue with Cascading Style Sheets and how CSS rules are overridden. I don't really have a place I can tell people about things I find out about web development and design and the various technologies associated with it, but I have this 'blog. I know some of you deal with CSS and such on a regular basis, and this might be useful for somebody out there.

So, to start out, here's some HTML structure. It's fairly standard structure, though greatly simplified. I won't include any CSS at this point, I just want to show what kind of HTML I'm working with.

<html>
<head>
  <title>Testing CSS</title>
</head>
<body>
<div id="container">
  <div></div>
  <div class="test"></div>
  <div class="test"></div>
  <div></div>
</div>
</body>
</html>
So, we have a container element with some divs in it. Some have a class that sets them apart from the others, so they can be styled differently. Let's see what we can do about that style.

#container div {
  border: solid black 1px;
}

.test {
  border: solid red 1px;
}
This says that all divs within the container div should have a solid, black, 1 pixel border, and all elements with the .test class should have the same border, but red. Simple, and straight-forward, right? Not quite. Since the first rule matches all the divs with the .test class, and includes the ID of an element, it won't be overridden by the less-specific second rule.

It's odd, but true. Give it a try sometime.

EDIT: I may have just secured my nomination for 'biggest geek'. What with posting about the oddities of CSS on my WoW tanking blog.

EDIT2: Changed my description and the CSS to the right class names.

Posted in Non-Tanking
Comments 2 Email Blog Entry
Total Comments 2

Comments

Old
Alent's Avatar
Wierdness like this is why I use a hybrid of tables and divs for my layouts.

inheritance with CSS is random from browser to browser, so I work to create a situation where there is no inheritance at all.
Posted 11-07-2008 at 10:30 AM by Alent Alent is online now
Old
veneretio's Avatar
Pure CCS myself. Although for my WoW blog, I just let Wordpress do all the work for me.
Posted 11-07-2008 at 01:43 PM by veneretio veneretio is offline
 
Recent Blog Entries by Thireas