WordPress.org

Ready to get started?Download WordPress

Forums

Every other row gray (5 posts)

  1. SharonGardner2012
    Member
    Posted 1 year ago #

    Hi I'm new to WP and am trying to create a table that has every other row highlighted with gray to make the rows stand out. Any suggestions?

  2. Krishna
    Volunteer Moderator
    Posted 1 year ago #

    Post a link of your site to demonstrate the problem.

  3. SharonGardner2012
    Member
    Posted 1 year ago #

    This is the page. If you scroll to the bottom you can see all the contacts. How can I do every other line as gray?

    http://hyfca.org/?page_id=198

    Thanks,
    Sharon

  4. WPyogi
    Volunteer Moderator
    Posted 1 year ago #

    One way to do it is to add a class to every other table line -- and then add CSS to color those lines grey -- for example:

    <table>
    <caption>Board of Direc­tors</caption>
    <tbody>
    <tr>
    <td align="center">...</td>
    <td align="center" width="212">...</td>
    <td align="center">...</td>
    </tr>
    <tr class="rowcolor">
    <td>Jean-Paul Velazquez</td>
    <td>Pres­i­dent</td>
    <td>...</td>
    </tr>
    <tr>
    <td>Mike Pas­sarelli</td>
    <td>Vice Pres­i­dent</td>
    <td>...</td>
    </tr>
    <tr class="rowcolor">
    <td>Sam New­man</td>
    <td>Sec­re­tary</td>
    <td>...</td>
    </tr>

    then CSS, for example:

    tr.rowcolor {
       color: grey;
    }

    How did you create the table?
    You might also want to fix some outdated CSS coding in it:

    http://validator.w3.org/check?uri=http%3A%2F%2Fhyfca.org%2F%3Fpage_id%3D198%26doing_wp_cron%3D1348760023.7131700515747070312500&charset=%28detect+automatically%29&doctype=Inline&group=0

  5. alchymyth
    Forum Moderator
    Posted 1 year ago #

    if you don't care for older browsers, try to add this to style.css - specific to that one page:

    .post-198 table tr:nth-child(odd) { background: #eee;}

    http://www.w3schools.com/cssref/sel_nth-child.asp

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags