views:

69

answers:

8

I have the following HTML:

<div id="graphicArea">
    <div id="page1" class="pageArea land"></div>
    <div id="page2" class="pageArea land"></div>
</div>

my CSS stylesheet file snippet (this works):

.pageArea {
    width:220px!important;
    height:210px!important; 
 }

my CSS stylesheet file snippet (this don't work):

.pageArea.land {
    width:220px!important;
    height:210px!important; 
 }

neitheir this works:

div.pageArea.land {
    width:220px!important;
    height:210px!important; 
 }

There is not much in this file further on, so I'm pretty sure it's not overriding the css. Anyone know why cant it work?

Thanks.

EDIT

All this css is within @media print { .. }. I don't think its relevant though.

EDIT2

Does FF has any issue regarding setting a div height/width in mm? I guess that's the whole point...

A: 

You have to put a space before .land.

So, instead of .pageArea.land, say .pageArea .land in your CSS.

bitmask
The HTML in the question has `class="pageArea land"`, so the `.land` element is *not* a child of the `.pageArea` element, and so `.pageArea .land` is wrong -- `.pageArea.land` is correct.
Daniel Pryden
Hey, thanks for the correction. I think I confused #graphicArea with .pageArea. Of course, then it should have been #graphicArea .land, which is not quite what is required in the question.
bitmask
+1  A: 

.pageArea.land means that the element you're targeting has 2 classes, pageArea and land.

How is your HTML laid out? Is .land a child of .pageArea? If so you just need a space between them, i.e.

.pageArea .land { .... }

Marko
Well now that you've provided html, my answer isn't valid and has been answered by others.
Marko
A: 

you have the dot of land in the pageArea , It must look like div.pageArea, .land

Sotiris
I've already tried this. No effect.
kaneda
@laramaki you need to show some HTML. Everything done here is guesswork otherwise.
Pekka
seperate them with comma. In fact It would help us if you inform what you try to achieve because your code seems very strange with all these `!important`.
Sotiris
The HTML in the question has `class="pageArea land"` so this is incorrect -- the OP wants to select and element with *two* CSS classes, not nested elements (which would require a space) or elements with either one or the other class (which would require a comma).
Daniel Pryden
I read it first time this with comma :O can you provide me link that explain further your whole comment? I am very curious about this..
Sotiris
+1  A: 

Try this:

 <div id="page1" class="pageArea land"></div>


.pageArea {
    width:220px!important;
    height:210px!important; 
 }

.land {
    width:220px!important;
    height:210px!important; 
}
gmcalab
@gmcalab I've tried it. Doesn't work either.
kaneda
+2  A: 

According to the CSS 2.1 specification, your code should work. Are you using Internet Explorer 6?

edit 1: .class1.class2 works with Chrome, and probably other browsers as well. Are you sure your selector is not working? Try "display: none" to be really sure.

Pierre Gardin
@Pierre Gardin I'm using FF3.6
kaneda
So are you sure your CSS selector is not working? I'm pretty sure it's working but you think it isn't because it's overridden or something like this.
Pierre Gardin
A: 

You have to have a space between .pageArea.land like this .pageArea .land You can try the following css structure
div#page1 .pageArea{ css goes here }

div#page1 .land{ css goes here }

div#page2 .pageArea{ css goes here }

div#page2 .land{ css goes here }

Gil Duzanski
A: 

Use Firebug to determine which styles are influencing the final appearance of these elements, once the cascade is applied.

Given the small snips HTML and CSS you've given us, it looks alright, yet you are telling us that you're not getting the desired result. Add to that your superfluous use of !important, and I think it's safe to conclude that your stylesheet contains many conflicting properties that aren't shown in your code sample, and one or more of them are influencing .pageArea.land.

Jesse Dhillon
The problem is I think I cant use firebug because those css are just used for printing. Even more, the class land is just added on runtime for purposes of printing and is not referenced nowhere else in the code.
kaneda
For debugging purposes, apply the stylesheet to screen instead of print, and add the `pageArea land` class attribute to the element using Firebug.
Jesse Dhillon
A: 

EDIT All this css is within @media print { .. }. I don't think its relevant though.

If it's in @media print { } the css will be applied when PRINTING

To have it be applied in the browser use @media screen { }

And if you want to see it in both print and on screen use @media screen, print { }

Chad