CSS class - H2 style not showing

I have 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 displayed, but a-style works:

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

I don't seem to know anything about CSS?

+5
source share
2 answers

This is because you have a class applied to div. Do this instead:

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

Alternatively, you can do this if you want to leave it in a div:

.spielbox h2 {
    margin-bottom:80px;
    color:#f00;
}
  • h2.spielboxmatches h2elements with classspielbox
  • .spielbox h2matches h2elements that are inside any element with a classspielbox
+9
source

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

<h2 class="spielbox">...</h2>
+2
source

All Articles