Forums

Correct CSS referencing a class? (3 posts)

  1. michaelmcguk
    Member
    Posted 1 year ago #

    Hi!

    I have a line in one of the pages:
    <ul><li class="page_item page-item-5"><a href="http://www.sitename.com/wordpress/?page_id=5" title="Standing out by standing for">Standing out by standing for</a></li></ul>

    Now, I was wondering if I want to make this particular link have a different color background(say), how do I do this in CSS?

    I've tried li.page_item .page-item-5 {background-color:#000}; but it doesn't seem to like it :(

    Please help. Tearing hair out here.

  2. Kafkaesqui
    Moderator
    Posted 1 year ago #

    Keep in mind multiple classes can be assigned through a single class attribute. So

    class="page_item page-item-5"

    is two classes (a space delimits them): page_item, the default generic class for list items output by wp_list_pages(), and page-item-5, obviously the class for a specific Page (ID).

    With that in mind, this:

    li.page-item-5 {
    	background-color: #000;
    }

    should effect the whole <li> line for your "Standing out by standing for" Page. For just the link (<a>) component of the line:

    li.page-item-5 a {
    	background-color: #000;
    }
  3. michaelmcguk
    Member
    Posted 1 year ago #

    Brilliant. You're a legend.

    Many thanks, it worked a treat :D

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.