views:

125

answers:

6

Apoologies in advance for the slightly long winded code in this question

@charset "UTF-8";
/* CSS Document */

* {
    margin:0;
    padding:0;
    font-family:Arial, Helvetica, sans-serif;
}

#wrapper {
    width:900px;
    margin:0 auto 0 auto;
}

#header {
    background-color:#800080;
    width:894px;
    min-height:60px;
    padding-top:6px;
    padding-left:6px;
}

#header img {
    margin-left:200px;
    margin-top:10px;
}

#headerleft {
    float:left;
}

#header h2 {
    font-family:Arial Black, Arial, Helvetica, sans-serif;
    color:#ffff00;
    font-size:36px;
    /*float:left;*/
    }

#header h3 {
    font-family:Arial Black, Arial, Helvetica, sans-serif;
    color:#ffff00;
    font-size:14px;
}

#nav {
    background-color:#800080;
    width:100%;
    min-height:30px;
}

#nav ul {
    padding-left:7px;
    padding-right:7px;
}


#nav li {
    list-style:none;
    display:inline;
    padding:5px 44px 5px 44px;
}

#nav li a {
    color:#FFF;
    text-decoration:none;
}

#nav li a:hover {
    color:#ffff00;
}


#leftcol {
    background-color:#800080;
    width:125px;
    min-height:30px;
    float:left;
}

#leftcol img {
    margin-left:20px;
    margin-bottom:20px;
}

.content {
    padding:20px 10px 10px 20px;
    float:left;
}

<!-- admin classes -->
.pageselect p {
    color:#C90;
}


#rightcol {
    /*background-color:#800080;*/   
    width:160px;
    min-height:330px;
    float:right;
}

.righthead {
    margin-top:7px;
    background-image:url(../images/rightcol-head.png);
    color:#FFF;
    padding: 5px 20px 5px 20px;
    font-size:14px;
}

.rightmid {
    background-image:url(../images/right-mid.jpg);
    padding: 5px 10px 5px 10px;
    font-size:14px;
}

.rightfoot {
    background-image:url(../images/right-foot.jpg);
    background-repeat:no-repeat;
}

.clear {
    clear:both;
}

#footer {
    background-color:#800080;
    width:880px;
    min-height:30px;
    margin-top:-20px;
    padding-top:30px;
    padding-left:20px;
    padding-bottom:10px;
}

#footer p {
    color:#ffff00;
}

#footer p a {
    color:#ffff00;
    text-decoration:none;
}

#footer p a:hover {
    font-weight:bold;
}

.error {
    color:#C30;
}

I have the above stylesheet. I am attempting to style the following element (taken from firefox web developer tools):

html > body > div#wrapper > div#leftright > div.content > div.pageselect

To my mind .pageselect should be the selector to do that, but I seem to be powerless to influence the style, and its just about sending me wacko!

Why won't this work?

edit for comments:

<div class="pageselect">
<p>
page
</p>
</div>

Everything is defined by a id on its own or by a single class, just the way I code.

+8  A: 

Hey YsoL8,

The only style I can see that you have for pageselect is

.pageselect p {
    color:#C90;
}

This would color a paragraph inside pageselect. Not pageselect itself. It should just be

.pageselect {
    color:#C90;
}

EDIT

Ok I think I found your problem. Your comment is wrong and messing with the style. You have,

<!-- admin classes -->
.pageselect p {
    color:#C90;
}

If that is in your css file then its wrong. You need to make this be like your other comments.

/* admin classes */
Metropolis
A: 

your css is styling .pageselect p, not just .pageselect

derek
+3  A: 

Have you conssidered using Firefox's Firebug extension to understand if the properties you are willing to define aren't defined somewhere else?

Pedro Morte Rolo
this is the only place the property is defined. It is a new class for its purpose.
YsoL8
Firebug will let you see the cascade of all rules targetting and affecting a specific element, so you'll be able to see if the rule is 'missing' the target or if it's being out-specified by another rule.
LeguRi
Firebug is really good for working out CSS strangeness - you can see exactly what styling is being applied to each element, what is being inherited from what definitions, and what is being overridden.I would say trying to design and develop web pages using CSS without Firefox is making things far too difficult.
Ken Ray
I'll certainly try it.
YsoL8
+13  A: 

Dude

Why do you have an HTML comment in your CSS?

<!-- admin classes -->
.pageselect p {
    color:#C90;
}

That should be:

/* admin classes */
.pageselect p {
    color:#C90;
}

Take note that in some browsers a CSS rule's selector can be spread between two lines:

.pageselect
p {
    color:#C90;
}
/* that was the same as
.pageselect p {
    color:#C90;
}
*/

So your HTML comment <!-- --> is being interpreted as part of a CSS selector. Since it makes no sense as a CSS selector, your whole rule is dropped.

LeguRi
I FEEL so STUPID. I can never go out again!
YsoL8
Don't feel half as stupid as the rest of us insisting you hadn't given enough CSS or HTML or that you were only targeting a `<p>` when the answer was right there all along :P
LeguRi
A: 

i guess you have a cascade specificity issue. ID-based selectors (starting with #) take precedence over Class-based selectors (starting with .) and both take precedence over Element-based selectors (just the elements' name, like p). and they sum up, which is interestign to note. let's say you have this markup:

<div id="this-div" class="div-class">
  <p id="this-paragraph" class="paragraph-class">
   text text text.
  </p>
  <p> other text </p>

then #this-div{color:blue;} will override p.paragraph-class{color:red;} regardless of the order you put it in the css file. think like this: each #id-based-selector is worth 100 specificity and each .class-based selector is worth 10 and each element-based selector is worth 1.

see http://www.w3.org/TR/CSS2/cascade.html#specificity for more details.

barraponto
A: 

CSS styles will be applied with a specific order. Class identifiers are overridden by more specific id identifiers, and if also if tag name is specified in addition, it will override a more general definition.

Example:

CSS:

div#myId{
  color: yellow;
}

div.myClass{
  color: green;
}

#myId{
  color: blue;
}

.myClass{
  color: red;
}

HTML:

<div id="myId" class="myClass">
  This will be yellow because the rule div#myId is more specific 
  than #myId and .myClass
</div>

<div id="anotherId" class="myClass">
  This will be green because the rule div.myClass is more specific 
  than .myClass
</div>

<span id="myId" class="myClass">
  This will be blue because the rule #myId is more specific 
  than .myClass
</span>
awe