Chicago Internet Professionals
Welcome, Guest. Please login or register.
September 08, 2010, 05:22:57 PM

Login with username, password and session length
Search:     Advanced search
Visit our three meetup groups Chicago Northside , Elmhurst and Chicago Southside to meet fellow professionals.
Sponsored by Chicago Web Management
84 Posts in 55 Topics by 26 Members
Latest Member: jobs@marcelmedia.com
* Home Help Calendar Login Register
+  Chicago Internet Professionals
|-+  Design (layout and interface)
| |-+  CSS Design and Techniques
| | |-+  Creating Stylesheets - Referencing Styles
« previous next »
Pages: [1] Print
Author Topic: Creating Stylesheets - Referencing Styles  (Read 788 times)
deconspray
Newbie
*

Karma: 0
Posts: 20



WWW
« on: April 29, 2009, 11:22:47 AM »

I'm fairly comfortable using CSS. However, one thing I continue to suffer agnst from is referring to styles in external stylesheets.

Say for instance I'm styling some elements within a <div> with a class of .item. This <div> is nested within several layers of other <div> tags.

I may write some styles like this:

Code:
.item {
      float:left;
      width:100%;
}

.item .heading{
      float:left;
      width:100%;
      background:#8c8070;
}

.item .heading h3{
      float:left;
      width:45%;
      margin:0px;
}

.item .heading price{
      float:right;
      width:45%;
}

When I view this, my <h3> still carries the more global styles. It's only when I provide some of the other classes & ids higher in the chain that the style works as expected. Example:

Code:
#content .twohigher .onehigher .item .heading h3{
      float:left;
      width:45%;
      margin:0px;
}

Can someone explain the rule of how to reference styles in the markup from an external stylesheet? Just looking to reduce my troubleshooting time.

Thanks in advance.
Logged

Neil_in_Chicago
Newbie
*

Karma: 0
Posts: 3


« Reply #1 on: April 29, 2009, 11:04:08 PM »

The keyword you're looking for is "precedence".
w3.org specifies The cascade.
Logged
Pages: [1] Print 
« previous next »
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC | Managed by Chicago Web Management Valid XHTML 1.0! Valid CSS!