- This topic is empty.
Viewing 4 posts - 1 through 4 (of 4 total)
Viewing 4 posts - 1 through 4 (of 4 total)
- The forum ‘CSS’ is closed to new topics and replies.
The forums ran from 2008-2020 and are now closed and viewable here as an archive.
Hello.
I would like to understand why the following can’t be applied to h2:
item-page h2:first-child a{
text-decoration:none;
text-align:left;
line-height:27px;
font-size:28px;
margin-bottom:10px;
font-weight:bolder;
color:#000;
background:red;
}
I can’t understand why h2 is not getting the styles.
Thanks in advanced for your time and help.
Because the `h2` is *not* the first child, the `h1` is the first child element of `.item-page`. You’re probably looking for `h2:first-of-type` but that is not supported by IE7 & IE8.
First item-page should be `.item-page`, but assuming that one was just a copy-paste typo. Well h1 is the first-child of item-page, rather than h2. If you’d want the h2 to get that style, maybe you would be looking for `:first-of-type` selector.
Yes, the missing dot was a copy/paste typo.
:first-of-type did the work.
I thought that :first-child meant the first h2 in .item-page …
Thanks a lot for clarifying that.