473,385 Members | 1,712 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Style Table Cell

Hello,

I have a table and I am styling its cells:

table.Grid td {background-color: red;}

Inside this table I will have some other tables but I don't want their
cells to have the styles changed.

I see two options: give a class to Grid table cells:
table.Grid td.Grid {background-color: red;}

Reset the changes in child tables:
table.Child1 td, table.Child2 td, table.Child3 td {background-color:
white;}

But can I apply the following style:
table.Grid td {background-color: red;}

And make it only for the cells inside that table but not inside the
child tables in this code line?
.... without needing to reset the styles on child table cells or give
main cells a class ...

Thanks,
Miguel
Jun 27 '08 #1
2 1703
* shapper wrote in comp.infosystems.www.authoring.stylesheets:
>table.Grid td {background-color: red;}

Inside this table I will have some other tables but I don't want their
cells to have the styles changed.
There are two options, either pick a selector that does not select the
descendants you don't want to select, or override the styles with other
rules. For the former you could use the child combinator, ala

table.Grid thead td { ... }

This would only match td elements whose parent is a thead whose parent
is a table element with class=Grid. This would work in most current
browsers except IE6. The other method would simply be

table.Grid td { ... set ... }
table.Other td { ... override ... }
--
Björn Höhrmann · mailto:bj****@hoehrmann.de · http://bjoern.hoehrmann.de
Weinh. Str. 22 · Telefon: +49(0)621/4309674 · http://www.bjoernsworld.de
68309 Mannheim · PGP Pub. KeyID: 0xA4357E78 · http://www.websitedev.de/
Jun 27 '08 #2
Bjoern Hoehrmann schrieb:
table.Grid thead td { ... }
missing tr:
table.Grid thead tr td { ... }

--
Johannes Koch
In te domine speravi; non confundar in aeternum.
(Te Deum, 4th cent.)
Jun 27 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: r_mun | last post by:
Hello, I think it would be an interesting issue to everyone. What I'd like to do is simply change the style of my dynamically created table cell. I have written the following code to...
4
by: jarek | last post by:
Hi, this is my code: CSSStyleDeclaration.prototype.__defineSetter__('display', displaySetter); function displaySetter(value) { var parent = findParent(document, this); if (parent) {
2
by: kigerm | last post by:
Hey guys, Here is my problem. I have a page consisting of a table with one row and 2 cells. Inside the first cell is a table that serves as a table of contents. That table has several rows with...
4
by: NvrBst | last post by:
I have a log viewer. I sort the DataGridView by the Time Column and then run a function to set all cell backcolors depending if the cell above is different. This works correctly, however, when...
6
by: Bob Altman | last post by:
Hi all, I have a table whose style is: ..main_table { border: thin solid #000000; width: 666px; border-collapse: collapse; }
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.