Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS class - H2 style not showing

Tags:

css

I've got this in my .css file:

h2.spielbox {
    margin-bottom:80px;
    color:#f00;
}

a.spielbox {
    text-decoration:none;
    background-color:#aff;
}

But in my html file the h2 style is not showing, while the a-style works:

<div class="spielbox" style="float:left;width:320px"><h2>Testberichte</h2>

Seems i am not knowing something about CSS ?

like image 855
Karl H. Avatar asked May 29 '11 18:05

Karl H.


2 Answers

you have set the spielbox class for h2, so you need to type it in h2,

<h2 class="spielbox">...</h2>
like image 22
Kamil Avatar answered Oct 20 '22 15:10

Kamil


It's because you have the class applied to a div. Do this instead:

<h2 class="spielbox">Testberichte</h2>

Alternately, you can do this if you want to leave it in the div:

.spielbox h2 {
    margin-bottom:80px;
    color:#f00;
}
  • h2.spielbox matches h2 elements with the class spielbox
  • .spielbox h2 matches h2 elements that are within any element with the class spielbox
like image 109
Wesley Murch Avatar answered Oct 20 '22 15:10

Wesley Murch