473,378 Members | 1,479 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,378 software developers and data experts.

multiple classnames

I have a table that I would like to style cell background colors. I'd
like to style rows and columns and give an "intersecting" cell a
different background color. That cell may look like this:

<td class="row_1_class column_1_class">selected cell</td>

Can I set a style that will only apply to an element that has both
classes?

Jeff
Jul 21 '05 #1
4 2401
Jeff Thies wrote:
Can I set a style that will only apply to an element that has both
classes?


..foo.bar {

}

.... except that Internet Explorer is a buggy little beast and will (IIRC)
treat it as .foo, .bar { } (or maybe it was .foo { }).

--
David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
Home is where the ~/.bashrc is
Jul 21 '05 #2
"Jeff Thies" <je**@spamalanadingong.com> wrote in message
news:gB*****************@newsread2.news.atl.earthl ink.net...
I have a table that I would like to style cell background colors. I'd
like to style rows and columns and give an "intersecting" cell a different
background color. That cell may look like this:

<td class="row_1_class column_1_class">selected cell</td>

Can I set a style that will only apply to an element that has both
classes?


The following style works when used in a valid HTML4.01-Strict document.
Tested in IE6, Firefox1.0.4 and Opera8.01 and Opera6.04

<style type="text/css">
.tablecolumn{background-color:#FF0000}
.tablerow{background-color:#00FF00}
.tablerow .tablecolumn{background-color:#FFFF00}
</style>
Jul 21 '05 #3
Danny@Kendal:
"Jeff Thies" <je**@spamalanadingong.com>
I have a table that I would like to style cell background colors. I'd
like to style rows and columns and give an "intersecting" cell a different
background color.

'background' is one of the few properties that applies to boxes with
'display' set to 'table-column' (or 'table-column-group'), like HTML's
'col' (or 'colgroup') element type. Of course it also applies to
'table-row' ('tr'). You will only see the top-most non-transparent
background, i.e. the one of the deepest nested box.

CSS 'display' | HTML element type
----------------------+-----------------------
table | table |
(> table-caption | > caption) ¦ table-column-group | > colgroup |
table-column | >> col | layer table-row-group | > thead, tfoot, tbody |
table-row | >> tr |
table-cell | >>> th, td V


In the tree models of CSS and HTML every element instance can be the
child of only one parent (and so forth, iterated up to :root), so it has
only one ancestary line from which it can inherit. Therefore a table
cell inherits from a row, but not from a column. IOW, "tr td {foo: bar}"
works, but "col td {foo: baz}" does not and of course there is no double
ancestor selector like hypothetically "tr&col td"---not even in IE that
has a non-conformant implementation of tables, which allows some other
desired stuff for columns (like 'text-align' or 'color').

There have been several proposals to add some kind of column selector to
CSS, but as of yet they were all flawed; mostly in that they do not
resolve the paradoxon, that you could select something depending on a
certain property and then change that very property, so the selector
should not have matched in the first place and the rule would not have
been used and so on.

Anyhow, there are more or less advanced concepts to deal with this
issue, but not a perfect one.

...<col class="bar">...
<tr>...<td>Quuz</td>...</tr>
<!-- or -->
<tr>...<td class="bar">Quuz</td>...</tr>

<tr class="foo">...<td class="bar">Baz</td>...</tr>

.foo {background: #F00}
.bar {background: #847}

.foo .bar {background: #ABC} /* can fail with nested tables */
/* or */
.foo>.bar {background: #ABC} /* fails in CSS1 browsers like IE */
/* or */
.foo > .bar {background: #ABC} /* can fail in IE */

or

<tr><td>...</td><td class="bar">Quuz</td>...</tr>
<tr><td class="foo">Quuz</td><td class="foo bar">Baz</td>...</tr>

.foo {background: #F00}
.bar {background: #847}

.foo.bar {background: #ABC} /* works wrongly in IE */
/* or */
.bar.foo {background: #ABC} /* works wrongly in IE */

or

<tr><th><td><td>Quuz</td>...</tr>
<tr class="foo"><th><td><td>Baz</td>...</tr>

.foo {background: #F00}

th+td+td {background: #847}
/* or */
tr>th+td+td {background: #847}
/* or */
tr>:first-child+*+* {background: #847}
/* or */
tr>*:first-child+*+* {background: #847}
/* or */
th:first-child+td+td {background: #847}
/* ... */

.foo>th+td+td {background: #ABC}
/* or */
.foo>:first-child+*+* {background: #ABC}
/* or */
.foo>th+*+* {background: #ABC}
/* or some other combination thereof */
/* beware of 'Rowspan' and 'colspan' */
/* '>' and '+' fail in IE, I'm not sure about ':first-child' */

and some variations.
.tablerow .tablecolumn{background-color:#FFFF00}


That is not the same as

.tablerow.tablecolumn{background-color:#FFFF00}

though, which the OP asked for.
Jul 21 '05 #4

"Jeff Thies" <je**@spamalanadingong.com> wrote in message
news:gB*****************@newsread2.news.atl.earthl ink.net...
I have a table that I would like to style cell background colors. I'd
like to style rows and columns and give an "intersecting" cell a different
background color. That cell may look like this:

<td class="row_1_class column_1_class">selected cell</td>

Can I set a style that will only apply to an element that has both
classes?

Jeff


Hi jeff

i need to do this recently and so i:
<td class="first_class"><span class="second_class">text</span></td>
Maybe this would work in your context?

Penrose
Jul 21 '05 #5

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

Similar topics

6
by: Rolf Wester | last post by:
Hi, I have a form with a select element with multiple="true". When using the GET method (I suppose the same happens with the POST method) I can seen that the form sends channels=CH1&channels=CH2...
66
by: Darren Dale | last post by:
Hello, def test(data): i = ? This is the line I have trouble with if i==1: return data else: return data a,b,c,d = test()
11
by: Ohaya | last post by:
Hi, I'm trying to understand a situation where ASP seems to be "blocking" of "queuing" requests. This is on a Win2K Advanced Server, with IIS5. I've seen some posts (e.g.,...
32
by: Will Hartung | last post by:
Can someone clarify that multiple classes in the "class" attribute are ok and "legal" and not some fluke? So, I can do: ..pink {color: pink} ..bold {font-weight: bold} ..medium {font-size:...
6
by: Ben Hallert | last post by:
Hi guys, I'm trying to figure out what bone headed mistake I made on something I put together. I've got a form (named 'context') that has a variable number of select-multiple inputs on it. ...
0
by: Bill Cohagan | last post by:
Is there a way to control generated classnames when generating classes from an XSD using xsd.exe? When generating typed datasets it's possible to provide some direction via the "codegen" namespace...
22
by: Matthew Louden | last post by:
I want to know why C# doesnt support multiple inheritance? But why we can inherit multiple interfaces instead? I know this is the rule, but I dont understand why. Can anyone give me some concrete...
8
by: mscertified | last post by:
I have two stylesheet files, one is a standard file and one a custon file. They have no classnames in common. How do I specify that my page use both stylesheets? I tried Help and as usual could...
35
by: keerthyragavendran | last post by:
hi i'm downloading a single file using multiple threads... how can i specify a particular range of bytes alone from a single large file... for example say if i need only bytes ranging from...
14
by: Jeff | last post by:
Let's say we have this: <div class="some_class some_other_class"> Is it possible to change *one* of the classnames. Jeff
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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?
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...

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.