WordPress.org

Ready to get started?Download WordPress

Forums

css target (7 posts)

  1. egilarntzen
    Member
    Posted 1 year ago #

    Can't "target" this with my CSS. What am I doing wrong?

    section#section1 .section white ul li {
    	display:inline;
    	background-color:#CF6;
    }
    <section class="section white" id="section1">
                <ul>
                <li><h2>Section 1</h2></li>
                <li><p>
                    ‘A fathomless and boundless deep,
                    There we wander, there we weep;
                    On the hungry craving wind
                    My Spectre follows thee behind.
                </p></li>
                </ul>
            </section>
  2. WPyogi
    Volunteer Moderator
    Posted 1 year ago #

    Try this:

    section.#section1 ul li {
    	display:inline;
    	background-color:#CF6;
    }

    If that does not work, please post a link to a page where this occurs.

  3. egilarntzen
    Member
    Posted 1 year ago #

    http://tomrerdahl.no/gabba/

    hmm... didn't work.

  4. egilarntzen
    Member
    Posted 1 year ago #

    Ok got it working...

    But its strange. I can't target the title inside the

    <li>.

    It works with

    article ul li {
    }

    if the code is

    <li>title</li>
    But if I want

    <li><h2>title</h2></li>
    it doesnt work with:

    article ul li {
    }

    Weird...

  5. Andrew
    Forum Moderator
    Posted 1 year ago #

    Have you tried targeting the h2 inside the li with CSS?

    Unless you target the "h2" it probably won't apply to the "<h2>"
    http://www.w3schools.com/cssref/css_selectors.asp
    http://coding.smashingmagazine.com/2007/07/27/css-specificity-things-you-should-know/

  6. egilarntzen
    Member
    Posted 1 year ago #

    I know, but if I for instance want a background color on the li, it should still work, no?

  7. Andrew
    Forum Moderator
    Posted 1 year ago #

    This isn't a normal situation because you're manipulating how the 'h2' is displayed
    http://stackoverflow.com/questions/7439820/why-is-my-background-color-not-showing-if-i-have-display-inline

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags