Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS Apply a background hover to a tag? Re: Apply a background hover to a tag?

#82380
wolfcry911
Participant

a link to a test page is all that is needed – thanks.

you have 18 errors on that page, but they’re all the same – there’s no end tag for images, just eliminate them.

You’re wrapping anchor tags around images which is fine, but also around h2s. While it’s perfectly acceptable in html5 some browsers will probably choke on it, and there’s really no reason to do so anyway – I’d move the anchor to inside the h2. This would solve the problem.

If you want to leave it as is, then you’re on the right path – you need to target the h2 within the anchor. The problem is the that background color is only as high as the line-height, which you’ve set to only 20% of the inline text box (under the h2 ruleset). Simply remove that line-height and address the spacing with the correct properties – margin. Set the h2 margin to zero and the following p top margin to 0.