Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Select all the table cells, but not the embedded table's cells

Tags:

css

selector

How do I select the cells in a table but not the cells of an embedded table? There is a question on how to do this in JQuery. I need to do this in CSS.

<table id="Outer">
    <tr>

        <td> --this one
        </td> 

        <td> --this one
            <table>
                <tr>
                    <td></td> -- but not this one or any deeper nested cells
                </tr>
            </table>
        </td>

    </tr> 
</table>
like image 455
Robert Avatar asked May 02 '11 18:05

Robert


People also ask

How can you select all of the cells in a table in Indesign?

Select cells To select a single cell, click inside a cell, or select text, and then choose Table > Select > Cell. To select multiple cells, drag across a cell border. Be careful not to drag the column or row line so that you don't resize the table.

How do I select all cells except first row?

Select the header or the first row of your list and press Shift + Ctrl + ↓(the drop down button), then the list has been selected except the first row.

How do I remove a table but keep the data in Excel?

To remove a table but keep data and formatting, go to the Design tab Tools group, and click Convert to Range. Or, right-click anywhere within the table, and select Table > Convert to Range.

How do I select only certain cells in Excel?

Press F5 or CTRL+G to launch the Go To dialog. In the Go to list, click the name of the cell or range that you want to select, or type the cell reference in the Reference box, then press OK. For example, in the Reference box, type B3 to select that cell, or type B1:B3 to select a range of cells.


2 Answers

You can use >, the child selector.
Example:

table#Outer > tbody > tr > td { color: red; }

The child selector selects only direct descendents. More on the child selector: http://meyerweb.com/eric/articles/webrev/200006b.html. But it's not supported by every web browser: http://www.quirksmode.org/css/contents.html.

like image 131
KatieK Avatar answered Oct 22 '22 06:10

KatieK


As given by a comment in the linked question:

table#Outer > tbody > tr > td {  }

Note that because of cascading, changes will apply to the inner table as well unless you provide a default override style for all cells:

td { background-color: white; }
table#Outer > tbody > tr > td { background-color:red; }

http://jsfiddle.net/95NAd/

like image 36
mellamokb Avatar answered Oct 22 '22 06:10

mellamokb