473,487 Members | 2,680 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Nested Classes

I have a table in which rows can be either of two kinds. One of the
columns can be styled in one of two ways. However, if the row is the
second style, then I want the column always to appear in the first
column style, regardless what the column's actual class was.

I wondered if I could use the following code:

..row1 { ... } /* define first row style */
..row2 { ... } /* define second row style */
..col1 { ... } /* define column style */
..row1 .col1 { ... } /* define special column style for first row style
/*

But that didn't work, so I ran some tests. After messing around a bit I

found that

..row1 { ... }
..row2 { ... }
..row1 .col1 { ... }

worked fine. So why didn't this work when the column style had an
earlier declaration?

Jul 21 '05 #1
6 4411
"Helge Moulding" <hm*******@gmail.com> wrote:
I have a table in which rows can be either of two kinds. One of the
columns can be styled in one of two ways. However, if the row is the
second style, then I want the column always to appear in the first
column style, regardless what the column's actual class was.

I wondered if I could use the following code:

.row1 { ... } /* define first row style */
.row2 { ... } /* define second row style */
.col1 { ... } /* define column style */
.row1 .col1 { ... } /* define special column style for first row style
/*
What element is col1 applied to? A <col> or a <td>?
But that didn't work,
Which part didn't work?
so I ran some tests. After messing around a bit I found that

.row1 { ... }
.row2 { ... }
.row1 .col1 { ... }

worked fine. So why didn't this work when the column style had an
earlier declaration?


Impossible to say as you haven't told us what the styles were, nor
what the relevant HTML is, nor whether you were using Standards or
Quirks mode, nor which browsers you tested in, nor in what way the
first one didn't work.

Steve

--
"My theories appal you, my heresies outrage you,
I never answer letters and you don't like my tie." - The Doctor

Steve Pugh <st***@pugh.net> <http://steve.pugh.net/>
Jul 21 '05 #2
Steve Pugh wrote:
Impossible to say as you haven't told us what the styles were, nor
what the relevant HTML is, nor whether you were using Standards or
Quirks mode, nor which browsers you tested in, nor in what way the
first one didn't work.


Firefox, quirks mode. Does that make a difference for this particular
behavior? (I know, everything makes a difference.)

Here's the test HTML that I initially wrote:

<html>
<head>
<style>
.type1 { color: red }
.type2 { color: green }
.type1 .type2 { color: blue }
</style>
</head>
<body>
<p class="type1">
Type 1 should be red.
</p>
<p class="type2">
Type 2 should be green.
</p>
<p class="type1">
More of type 1.
<blockquote class="type2">
Type 2 inside type 1 should be blue, but it isn't.
</blockquote>
</p>
</body>
</html>

What's weird is that if I rewrite it like this it (nesting classes)
works fine. It's weird because I can't see the real difference:

<html>
<head>
<style>
table, tr, td { border: solid 1px black; border-collapse:
collapse }
.row1 { color: red }
.row2 { color: green }
.col1 { background: white } /* this line isn't really needed */
.row1 .col1 { background: grey }
</style>
</head>
<body>
<table>
<caption>This mysteriously works right</caption>
<tr><td>Text</td><td class="col1">Special</td>
<td>Unstyled row with special column.</td></tr>
<tr class="row1"><td>Text</td><td>Not Special</td>
<td>Styled row without special column.</td></tr>
<tr class="row2"><td>Text</td><td class="col1">Special</td>
<td>Wrong styled row with special column.</td></tr>
<tr class="row1"><td>Text</td><td class="col1">Special</td>
<td>Styled row with special column.</td></tr>
</table>
</body>
</html>

Jul 21 '05 #3
Helge Moulding <hm*******@gmail.com> wrote:
<p class="type1">
More of type 1.
<blockquote class="type2">
Type 2 inside type 1 should be blue, but it isn't.
</blockquote>
</p>


BLOCKQUOTE elements can't go inside paragraphs. What you have there is the
equivalent of

<p class="type1">
More of type 1.
</p><blockquote class="type2">
Type 2 inside type 1 should be blue, but it isn't.
</blockquote>
</p>
--
Darin McGrew, mc****@stanfordalumni.org, http://www.rahul.net/mcgrew/
Web Design Group, da***@htmlhelp.com, http://www.HTMLHelp.com/

"Red meat isn't bad for you. Fuzzy blue-green meat is bad for you."
Jul 21 '05 #4
Helge Moulding wrote:

<p class="type1">
More of type 1.
<blockquote class="type2">
Type 2 inside type 1 should be blue, but it isn't.
</blockquote>
</p>


http://validator.w3.org/ is your friend. Paragraphs can not contain block
quotes. So if you are using HTML then you implicitly close the paragraph by
opening the blockquote (and then try to close a non-open paragraph
afterwards - which is invalid) and in XHTML you are trying to put the
blockquote where it is not allowed (also invalid).

Since the blockquote isn't inside the paragraph, it isn't a descendant of an
element of class "type1", so the selector doesn't match.

--
David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
Home is where the ~/.bashrc is
Jul 21 '05 #5
"Helge Moulding" <hm*******@gmail.com> wrote:
Steve Pugh wrote:
Impossible to say as you haven't told us what the styles were, nor
what the relevant HTML is, nor whether you were using Standards or
Quirks mode, nor which browsers you tested in, nor in what way the
first one didn't work.
Firefox, quirks mode. Does that make a difference for this particular
behavior? (I know, everything makes a difference.)


It might have made a difference. You simply didn't provide enough
details to rule anything out.
Here's the test HTML that I initially wrote:

<html>
<head>
<style>
Missing type attribute.
.type1 { color: red }
.type2 { color: green }
.type1 .type2 { color: blue }
</style> [...] <p class="type1">
More of type 1.
<blockquote class="type2">
Type 2 inside type 1 should be blue, but it isn't.


<blockquote> is not a valid child of <p>, hence the <p> is closed
before the <blockquote> is opened so it should NOT be blue as the
..type1 .type2 style can NOT be applied.

Steve

--
"My theories appal you, my heresies outrage you,
I never answer letters and you don't like my tie." - The Doctor

Steve Pugh <st***@pugh.net> <http://steve.pugh.net/>
Jul 21 '05 #6
Darin McGrew wrote:
BLOCKQUOTE elements can't go inside paragraphs. What you have there is the equivalent of


D'oh!

Jul 21 '05 #7

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

Similar topics

3
2389
by: Erik Bongers | last post by:
Hi, Nested classes only seem to be able to access static members of the surrounding class : class SurroundingClass { public: class InnerClass { public:
3
1204
by: Rubén Campos | last post by:
Organizing classes, types, structures, enums and whatever other entities into nested namespaces requires to include into every header and implementation file the complete path of namespaces. Let me...
6
559
by: B0nj | last post by:
I've got a class in which I want to implement a property that operates like an indexer, for the various colors associated with the class. For instance, I want to be able to do 'set' operations...
8
16850
by: Robert W. | last post by:
I've almost completed building a Model-View-Controller but have run into a snag. When an event is fired on a form control I want to automatically updated the "connnected" property in the Model. ...
2
2031
by: Bob Day | last post by:
Using VS2003, VB.NET, MSDE... I am looking at a demo program that, to my surprise, has nested classes, such as the example below. I guess it surprised me becuase you cannot have nested subs,...
2
2356
by: miked | last post by:
I am architecting in a read only class for use in mapping data to a business object. The object makes strong use of nested classes and their ability to access protected fields. The downside is...
5
2270
by: Jake K | last post by:
What purpose does nesting a class inside another class typically server? Are there conditions where this would be beneficial? Thanks a lot.
3
2105
by: Cousson, Benoit | last post by:
I don't think so; my original email was mainly a question. I do agree that they are other ways to do what I'm trying to achieve; there are always several ways to solve an issue. Few days ago, I...
0
143
by: Maric Michaud | last post by:
Le Tuesday 12 August 2008 23:15:23 Calvin Spealman, vous avez écrit : I was not aware of any "nested classes are unsupported" before and didn't consider nested classes as bad practice till...
2
2272
card
by: card | last post by:
Hi everyone, I have a question about referencing a nested class contained within a templated class. Of course the best way to show you is by example. Here's my templated classes: #include...
0
7106
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7137
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,...
1
6846
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7349
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5442
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4874
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
3071
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1381
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
600
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.