Benjamin
Benjamin

Reputation: 2118

css class inherit a heading

I have read posts about css inheritance and i am still left a bit lot.

Is this possible to do in css?

.cv3-envaleur h1 {
    background: none;
    font-size: 23px;
    line-height: 38px;
    color: #fff;
    margin: 0px 0 5px 0;
    padding: 10px 0px 5px 0px;
}

I have also tried this.

div.cv3-envaleur h1 {
    background: none;
    font-size: 23px;
    line-height: 38px;
    color: #fff;
    margin: 0px 0 5px 0;
    padding: 10px 0px 5px 0px;
}

I am trying to give some style to the H1 heading inside the div called .cv3-envaleur but i can't seem to make it work.

Please help

Upvotes: 0

Views: 1491

Answers (2)

ean5533
ean5533

Reputation: 8994

When you say the div is "called" cv3-envaleur, do you mean that its ID attribute is cv3-envaleur? If so, then you need to use the # selector, like so:

div#cv3-envaleur h1{ 
... 
}

Dot selectors are used for classes, not IDs.

Upvotes: 1

Dustin Laine
Dustin Laine

Reputation: 38503

Both of these are valid ways to do what you are after. There has to be something overriding these. You can check in Firebug as to what the current definitions are and what is overriding. You can also add the !important flag to force the style.

<div class="cv3-envaleur"><h1>Header</h1></div>

div.cv3-envaleur h1
{
    background: none !important;
    font-size: 23px;
    line-height: 38px;
    color: #fff;
    margin: 0px 0 5px 0;
    padding: 10px 0px 5px 0px;
}

Upvotes: 1

Related Questions