Search code examples
htmlcssstylesheet

How do I make my selectors more specific?


In a page I use a tabstrip with its own stylesheets. This tabstrip writen with divs and anchors.

I add some other divs into tabs but they inherit stylesheet from the outer tabstrip. This new divs has their own css classes.

Here is my question, are there a way to break this inheritance without changing the structure of css ?

Tabs' CSS Styles :

div.tabs {
    padding: .5em;
}
div.tabs div.tabs {
    padding: 0;
}
div.tabs div.tabs div {
    clear: left;
    height: 4em;
    padding: .5em;
    border: 1px solid #003366;
}

New added divs use this classes :

.graphTextItem{ font-family:sans-serif; font-size:12px; border: solid 1px #78ACFF; text-align:center; width:150px; }
.graphImageItem{ border-left: solid 1px #78ACFF; border-right: solid 1px #78ACFF; text-align:center; height:70px; }

Solution

  • By removing div from this stylesheet solved my problem :

    div.tabs div.tabs {
        clear: left;
        height: 4em;
        padding: .5em;
        border: 1px solid #003366;
    }
    

    But I still wonder whether there is a way ?