Results 1 to 3 of 3

Thread: How to target a specific row in a table??

  1. #1
    Join Date
    Oct 2008
    Location
    Sweden
    Posts
    2,023
    Thanks
    17
    Thanked 319 Times in 318 Posts
    Blog Entries
    3

    Default How to target a specific row in a table??

    I have a page with a table with three rows. I want to remove the second row. I do not have access to the page, I only have access to its css document. The row I want to remove does not have an id or a class. It only contains a non-breaking space. If I use
    Code:
    table tbody tr td {
    display:none
    }
    then I lose the third row which I actually need. Is there any way for me to target only the second row using css? It should be something like this:
    Code:
    table tbody tr td(second) {
    display:none
    }
    Of course that doesn't work but there should be something similar that works.

    Another solution would be to actually use the first option, which would hide the entire table, and then use css to make the third row display anyways instead of inheriting the display:none value. The third row does have a id value which I can use. Visibility:hidden and visible is not got since the row would still take up the space. I need to get rid of it.
    Please help me, thanks!
    Last edited by Snookerman; 04-22-2009 at 09:43 AM. Reason: added “Resolved” prefix

  2. #2
    Join Date
    Mar 2007
    Location
    Currently: New York/Philadelphia
    Posts
    2,735
    Thanks
    3
    Thanked 519 Times in 507 Posts

    Default

    You have two options here:

    1. Advanced CSS Selectors
    There is the nth-child() pseudo class selector. That would work in this case but it's not supported by all browsers.

    2. Use the third row's id
    If the snippet you posted gets rid of the second and third rows, add this below it to re-display the third row:
    Code:
    #third-row {
       display:block;
    }
    You would replace third-row with the id of the actual third row.

  3. #3
    Join Date
    Oct 2008
    Location
    Sweden
    Posts
    2,023
    Thanks
    17
    Thanked 319 Times in 318 Posts
    Blog Entries
    3

    Default

    Thanks, your second option was the first thing I tried, I tried both block, inline but it still didn't work. I realize now it is because the row itself does not have an id, it is a div container inside the third row that does. If I make it display it wont matter since the row it is in does not display. I'll take a look at your first option, hopefully it will work in most browsers.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •