Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS select all elements except h1

Tags:

css

Is it possible to do with CSS something like this:

CSS:

#right div.item-page, #right .newsflashlatest_news {
    padding: 0 133px 0 50px;
    text-align: justify;
}

#right .item-page h1, #right .newsflashlatest_news h1 {
    padding: 0 !important;
}

#right {
    float: left;
    width: 755px;
}

HTML:

<div id="right">
fsfds

<div class="item-page" style="background: blue;">
<h1>Home</h1>
<p>Pri iisque malorum ei, est te suavitate mediocritatem, facer molestie explicari vix ne. </p>
</div>
</div>

I need to apply the rules above to all elements in div.itemp-page except h1 element. Basically this means that all elements would have padding except h1 element.

Simply adding "#right div.item-page h1" somehow doesn't work for my case (see here: http://jsfiddle.net/Pr47M/)

like image 575
renathy Avatar asked Dec 04 '22 10:12

renathy


1 Answers

You can do something like this

#right div.item-page {
     padding: 0 133px 0 50px;  
     text-align:justify;
}
#right div.item-page h1 {
     padding: 0;  
     text-align:left;
}

Alternatively you can also do this

#right div.item-page *:not(h1) {
     padding: 0 133px 0 50px;  
     text-align:justify;
}
like image 144
edd Avatar answered Feb 08 '23 18:02

edd