By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,625 Members | 2,235 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,625 IT Pros & Developers. It's quick & easy.

Preventing Inheritance?

P: n/a
Bob
I need to apply a border to a table's columns, but not to the columns
of tables nested within (I realize nested tables are bad form, it's a
client request). I can't control what goes inside this table so
applying a class to any nested tables that cancels out this border
isn't an option. Is there any way to prevent the inheritance?
Jul 20 '05 #1
Share this Question
Share on Google+
15 Replies


P: n/a
Bob wrote:
I need to apply a border to a table's columns, but not to the columns
of tables nested within (I realize nested tables are bad form, it's a
client request). I can't control what goes inside this table so
applying a class to any nested tables that cancels out this border
isn't an option. Is there any way to prevent the inheritance?


It sounds like inheritance isn't the problem here, but that elements you
don't want to match your style definition are matching it as well as ones
you want to match.

Take a look at descendent selectors <http://w3.org/TR/CSS2/> and specify a
different value for the nested elements.

--
David Dorward <http://dorward.me.uk/>
Jul 20 '05 #2

P: n/a
"Bob" <bo******@hotmail.com> wrote in message
news:a4*************************@posting.google.co m...
I need to apply a border to a table's columns, but not to the columns
of tables nested within (I realize nested tables are bad form, it's a
client request). I can't control what goes inside this table so
applying a class to any nested tables that cancels out this border
isn't an option. Is there any way to prevent the inheritance?


Perhaps you should give your table an ID and apply the style to the ID
selector.

HTH
Regards,
Peter Foti
Jul 20 '05 #3

P: n/a
Bob
David Dorward <do*****@yahoo.com> wrote in message news:<c0*******************@news.demon.co.uk>...
Take a look at descendent selectors <http://w3.org/TR/CSS2/> and specify a
different value for the nested elements.


The problem is I would then be forcing that different value on all
nested elements. For example if I attempt to remove the border style
on nested tables (border:none), a table with the attribute "border=1"
would also lose its border.
Jul 20 '05 #4

P: n/a
Bob
"Peter Foti" <pe***@Idontwantnostinkingemailfromyou.com> wrote in message news:<10*************@corp.supernews.com>...

Perhaps you should give your table an ID and apply the style to the ID
selector.

HTH
Regards,
Peter Foti


True that would work, but I would end up needing a large number of IDs
for all the table cells. I just kinda figured there was a better way.
Jul 20 '05 #5

P: n/a
It seems "Bob" wrote in comp.infosystems.www.authoring.stylesheets:
I need to apply a border to a table's columns, but not to the columns
of tables nested within (I realize nested tables are bad form, it's a
client request). I can't control what goes inside this table so
applying a class to any nested tables that cancels out this border
isn't an option. Is there any way to prevent the inheritance?


Sure -- your stylesheet should contain one set of styles for table
td and a different set for table table td. The latter, being more
specific, will apply only to nested tables. The former will apply to
both outer and inner tables (except where overridden by table table
td).

--
Stan Brown, Oak Road Systems, Cortland County, New York, USA
http://OakRoadSystems.com/
HTML 4.01 spec: http://www.w3.org/TR/html401/
validator: http://validator.w3.org/
CSS 2 spec: http://www.w3.org/TR/REC-CSS2/
2.1 changes: http://www.w3.org/TR/CSS21/changes.html
validator: http://jigsaw.w3.org/css-validator/
Jul 20 '05 #6

P: n/a
On 11 Feb 2004 17:38:41 -0800, Bob <bo******@hotmail.com> wrote:
David Dorward <do*****@yahoo.com> wrote in message
news:<c0*******************@news.demon.co.uk>...
Take a look at descendent selectors <http://w3.org/TR/CSS2/> and
specify a
different value for the nested elements.


The problem is I would then be forcing that different value on all
nested elements. For example if I attempt to remove the border style
on nested tables (border:none), a table with the attribute "border=1"
would also lose its border.

Then use classes or ID's as well.
Jul 20 '05 #7

P: n/a
Bob
Stan Brown <th************@fastmail.fm> wrote in message news:<MP************************@news.odyssey.net> ...
Sure -- your stylesheet should contain one set of styles for table
td and a different set for table table td. The latter, being more
specific, will apply only to nested tables. The former will apply to
both outer and inner tables (except where overridden by table table
td).


But that isn't preventing inheritance, it's just forcing a new style
on the nested tables, and I don't necessarily want all nested tables
to look the same.

It's too bad you can't reverse-cascade, like applying a style to the
parents of a tag rather than its children/descendants.
Jul 20 '05 #8

P: n/a
On 11 Feb 2004 08:36:50 -0800, Bob <bo******@hotmail.com> wrote:
I need to apply a border to a table's columns, but not to the columns
of tables nested within (I realize nested tables are bad form, it's a
client request). I can't control what goes inside this table so
applying a class to any nested tables that cancels out this border
isn't an option. Is there any way to prevent the inheritance?

Bob, it's a little more coding than you want to do, clearly, but this will
do it.

First, write CSS for basic tables in your document. Then set an ID or
class on the parent table, and style that later in the CSS than the
general table style.

You're seemingly looking for a way to stop inheritance which is really an
essential part of CSS. It's not possible to turn it off without declaring
a conflicting style, or making style declarations to classes.

This serves as another good reason not to do table layout - borders are
not inherited by divs.

On the client request - if you were an architect in the snowy north, and
the client asked you to build a huge room with a flat roof and no roof
support, would you do it? Of course not, you know it's an unwise practice.
You at the very least endanger the structural integrity of the building,
if not the inhabitants.

Yet it never ceases to amaze me that web authors will do whatever the
client asks, even when they know it's poor practice, even when they know
it not only damages the structure and functionality of the page itself but
also makes people not want to be there.

I appreciate the need to keep business, but there's got to be a way to
make web authors as responsible and capable to the needs of the users as,
say, electricians, plumbers and architects. Maybe we ought to have a
licensing board for authors and they are compelled to use sound srtuctural
practices...
Jul 20 '05 #9

P: n/a

"Bob" <bo******@hotmail.com> wrote in message
news:a4*************************@posting.google.co m...
"Peter Foti" <pe***@Idontwantnostinkingemailfromyou.com> wrote in message

news:<10*************@corp.supernews.com>...

Perhaps you should give your table an ID and apply the style to the ID
selector.

HTH
Regards,
Peter Foti


True that would work, but I would end up needing a large number of IDs
for all the table cells.


Why?

#specialTable { ... }
#specialTable td { ... }

<table id="specialTable">
<tr><td>...
Jul 20 '05 #10

P: n/a
It seems "Bob" wrote in comp.infosystems.www.authoring.stylesheets:
Stan Brown <th************@fastmail.fm> wrote in message news:<MP************************@news.odyssey.net> ...
Sure -- your stylesheet should contain one set of styles for table
td and a different set for table table td. The latter, being more
specific, will apply only to nested tables. The former will apply to
both outer and inner tables (except where overridden by table table
td).


But that isn't preventing inheritance, it's just forcing a new style
on the nested tables, and I don't necessarily want all nested tables
to look the same.


So do you want to "prevent inheritance", or do you want to style
your page in a particular way? Perhaps I was wrong, but I thought it
was the latter. I don't know any way to do the former.

--
Stan Brown, Oak Road Systems, Cortland County, New York, USA
http://OakRoadSystems.com/
HTML 4.01 spec: http://www.w3.org/TR/html401/
validator: http://validator.w3.org/
CSS 2 spec: http://www.w3.org/TR/REC-CSS2/
2.1 changes: http://www.w3.org/TR/CSS21/changes.html
validator: http://jigsaw.w3.org/css-validator/
Jul 20 '05 #11

P: n/a
Bob
Neal <ne*****@spamrcn.com> wrote in message news:<op**************@news.rcn.com>...
Yet it never ceases to amaze me that web authors will do whatever the
client asks, even when they know it's poor practice, even when they know
it not only damages the structure and functionality of the page itself but
also makes people not want to be there.


CSS positioning is all well and good, but when the vast majority of
people are still using Internet Explorer, it's not always your best
option. Should the client tell me their customers are reporting
visual problems with the site, I can't very well tell them, "Please
advise the 90% of your customer-base still using IE to upgrade to
Mozilla. Problem solved!"
Jul 20 '05 #12

P: n/a
Bob
"Harlan Messinger" <h.*********@comcast.net> wrote in message news:<c0*************@ID-114100.news.uni-berlin.de>...
Why?

#specialTable { ... }
#specialTable td { ... }

<table id="specialTable">
<tr><td>...


Because the "#specialTable td" style would still apply to nested
tables that don't have that the "specialTable" id.
Jul 20 '05 #13

P: n/a
On 12 Feb 2004 18:24:09 -0800, Bob <bo******@hotmail.com> wrote:
Neal <ne*****@spamrcn.com> wrote in message
news:<op**************@news.rcn.com>...
Yet it never ceases to amaze me that web authors will do whatever the
client asks, even when they know it's poor practice, even when they know
it not only damages the structure and functionality of the page itself
but
also makes people not want to be there.


CSS positioning is all well and good, but when the vast majority of
people are still using Internet Explorer, it's not always your best
option. Should the client tell me their customers are reporting
visual problems with the site, I can't very well tell them, "Please
advise the 90% of your customer-base still using IE to upgrade to
Mozilla. Problem solved!"


See, I disagree that IE is so hopeless in CSS. There's a lot possible in
it. But as I said, you have to stay in business, and if the client won't
pay you unless you do something you'd rather not, you either do it or not
get paid.
Jul 20 '05 #14

P: n/a
On Thu, 12 Feb 2004, Neal wrote:
See, I disagree that IE is so hopeless in CSS.
I think that would have to be measured against the requirements of the
specification. (I mean, rather than the fact that - given enough
effort, study of its anomalies and various disregards of mandatory
requirements of the interworking specifications - it's possible to
work-around its misbehaviours and produce presentable web pages - the
latter is surely not in dispute, but it can hardly be said to command
the description of "supporting CSS".)
There's a lot possible in it. But as I said, you have to stay in
business, and if the client won't pay you unless you do something
you'd rather not,
.... then there was something wrong with the contract that you
accepted!
you either do it or not get paid.


On the other hand, you might find another customer who understands the
medium better, be glad that you dropped a troublesome customer who
really wanted a WYSIWYG deezyner rather than a true WWW engineer, and
the new customer not only pays you but also leaves you satisfied with
the job that you did.

But then, I can't speak from personal experience, since I do this
stuff as a sideline of a full-time employment. So YMMV and all that.
Jul 20 '05 #15

P: n/a
"Alan J. Flavell" <fl*****@ph.gla.ac.uk> wrote in
news:Pi*******************************@ppepc56.ph. gla.ac.uk:
On Thu, 12 Feb 2004, Neal wrote:
There's a lot possible in it. But as I said, you have to stay in
business, and if the client won't pay you unless you do something
you'd rather not,


... then there was something wrong with the contract that you
accepted!
you either do it or not get paid.


On the other hand, you might find another customer who understands the
medium better, be glad that you dropped a troublesome customer who
really wanted a WYSIWYG deezyner rather than a true WWW engineer, and
the new customer not only pays you but also leaves you satisfied with
the job that you did.


A very important point here is that if the reason a consulting professional
would "rather not" do something the client asks for is that his
professional judgment tells him it won't work out, taking on the work
anyway and doing it the client's way means that either one of two things
will happen:

1) It doesn't work out, and the client refuses to pay and goes to someone
else. Sure, if you had a contract that specified that you were going
against your best judgment and weren't responsible for the desired outcome,
you could sue. And, 5-10 years down the road, win. And get a judgment
that you could *try* to collect on. At best, you'd wind up with pennies on
the dollar.

2) It doesn't work out, and the client refuses to pay unless you redo the
job the right way. Twice the work for the same pay.

In *both* cases you'd have been better off turning down the job. If you do
it right (simply explaining, diplomatically, that what the client wants you
to do is against your professional judgment and that he would be better off
with someone whose professional judgment is different from yours--do *not*
employ that "brutal honesty" that geeks are famous for and cast aspersions
on his intelligence, parentage, etc--but that he can always come back to
you if he's not satisfied with the results he gets from someone else), then
there's a good chance that he'll get burned by someone else and will then
be willing to pay you to pick up the pieces.
Jul 20 '05 #16

This discussion thread is closed

Replies have been disabled for this discussion.