File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes HTML, CSS and JavaScript and the fly likes Preventing inheritance in a Div Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Preventing inheritance in a Div" Watch "Preventing inheritance in a Div" New topic
Author

Preventing inheritance in a Div

Rajesh Khan
Ranch Hand

Joined: Oct 16, 2011
Posts: 230
Hi i have a div inside another div as follows


Now the problem is what ever i apply to label also affects the label inside ClassA. Is there any way in which i could explicitly specify that the style should only be applied to the label whose direct parent is ClassA at the same time keeping classb inside classA
Elisabeth Barton
Greenhorn

Joined: Nov 16, 2011
Posts: 3
Hmmm well whenever I've used two different labels in one div before. Maybe separate them and see what happens?
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

The CSS selector "E F" matches any F element which is a descendant of an E element. The selector "E>F" matches any F element which is a child of an E element. (I got this directly from the CSS specification.) Was that what you had in mind?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60997
    
  65

Does your reference table for CSS3 selectors give you any clue?

(If you don't have one handy, now you know what your next task is.)

[Edit: Oh man, Paul snuck in before me!]


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

The CSS2 spec is one of the things sitting on my desk at the moment.
Greg Charles
Sheriff

Joined: Oct 01, 2001
Posts: 2848
    
  11

If you start a tag with <label>, you should end it with </label> not </lable>
Rajesh Khan
Ranch Hand

Joined: Oct 16, 2011
Posts: 230
Greg Charles wrote:If you start a tag with <label>, you should end it with </label> not </lable>

Thanks for pointing that out
Rajesh Khan
Ranch Hand

Joined: Oct 16, 2011
Posts: 230
Thanks guys i didn't know there were so many possibilities
http://www.w3.org/TR/CSS2/selector.html#class-html
I could have just used
.classA > label {color:Blue;background-color:Red}
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60997
    
  65

Modern browsers implement most of CSS3.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Preventing inheritance in a Div