Forums

  • # December 3, 2012 at 3:27 pm

    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.

    # December 3, 2012 at 3:32 pm

    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.

    # December 3, 2012 at 3:34 pm

    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.

    # December 3, 2012 at 3:56 pm

    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.

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.

icon-anchoricon-closeicon-emailicon-linkicon-logo-staricon-menuicon-nav-guideicon-searchicon-staricon-tag