473,513 Members | 2,428 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Add Padding to cell depending on neighbor

I seem to remember there is a way to modify an element based on what it
is next to, but I can't seem to locate it. Here's my scenario:

We have some pages that are built dynamically and present tabular data
(generally from a database). The generating application is smart
enough to use styles that left justify text (descriptions, etc.) and
right justify numbers (counts, dollars). However, if a right justified
column is smack up against a left justified column it is a little
difficult to read (we use a minimum of padding to maximize data on the
screen). I would love to define the style to add some padding in this
case. Is this possible?

Thanks a lot,

Daniel vom Saal

Aug 3 '06 #1
2 2360
dv******@ddrtech.com <dv******@ddrtech.comscripsit:
I seem to remember there is a way to modify an element based on what
it is next to,
You can use a contextual selector that selects an element according to the
element it follows, so that e.g. using the markup
... <td class="foo">...</td<td>stuff</td...
you could use the selector
td.foo + td
to select the "stuff" cell, since the selector matches any td element that
immediately follows another td element that has class="foo". The bad news is
that this doesn't work on IE 6. (It works on IE 7 beta.)

You can't do things in the opposite direction (to select an element
according to the element that follows it).
The generating application is smart
enough to use styles that left justify text (descriptions, etc.) and
right justify numbers (counts, dollars). However, if a right
justified column is smack up against a left justified column it is a
little difficult to read (we use a minimum of padding to maximize
data on the screen). I would love to define the style to add some
padding in this case. Is this possible?
It would be best if you could modify the generating application so that it
keeps track of what it has done and detects such a situation and emits a
class attribute that lets you specify the padding. That is, when it is about
to generate a cell that has left-aligned content, it checks whether the
previous cell on the same line was right-aligned and generates, say, <td
class="text padded"instead of just <td class="text">, and your CSS could
have something like
td.text { text-align: left; }
td.padded { padding-left: 0.2em; }

--
Jukka K. Korpela ("Yucca")
http://www.cs.tut.fi/~jkorpela/

Aug 3 '06 #2

Jukka K. Korpela wrote:
You can use a contextual selector that selects an element according to the
element it follows, so that e.g. using the markup
... <td class="foo">...</td<td>stuff</td...
you could use the selector
td.foo + td
to select the "stuff" cell, since the selector matches any td element that
immediately follows another td element that has class="foo". The bad news is
that this doesn't work on IE 6. (It works on IE 7 beta.)
Sigh. Thank you Microsoft (again); our client base is almost 100% IE.
It would be best if you could modify the generating application so that it
keeps track of what it has done and detects such a situation and emits a
class attribute that lets you specify the padding.
Sounds like that's what we'll have to do. Thanks for your reply; based
on the history of posts in this group I think I can take this as
gospel!

DvS

Aug 4 '06 #3

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

Similar topics

5
13092
by: Jonathan Daggar | last post by:
Hello, I'm trying to put together a form with a very tight table formatting. However, every time I put an text-type input field in, the browser pads the area to the right of it with space. I've...
3
10702
by: Steve Sabljak | last post by:
I seem to having a little trouble getting a table to display correctly in both msie and firefox. I want to set the table and column widths in pixels, and have some cell padding too. The table...
2
6742
by: StarQuake | last post by:
At this site: http://forwarding.robas.com You can see in IE there is cell padding in 'Berkman Bedrijven' and with Firefox there isn't. I don't want any cell padding. Anyone? --...
36
2984
by: phil-news-nospam | last post by:
Here is a simpler (no drop shadows) example of the padding bug I see: http://phil.ipal.org/usenet/ciwas/2006-05-08/buttons-1.html So far I find nothing in the CSS2 document that says I should...
5
10494
by: Tom | last post by:
I am having a problem where an extra gap (whitespace, padding) appears in a table cell where I don't want it. The data fed in the table is via dynamic HTML, so the amount in the middle cell may...
1
2185
by: Art | last post by:
Not sure whether the question is appropriate to the .html and/or ..stylesheets ng so I'm posting to both. I have been trying to find a solution to a problem regarding adding of the padding...
2
4727
by: shapper | last post by:
Hello, How can I define the cell padding and cell spacing of a table using a CSS class? Thanks, Miguel
12
16065
by: Koelner | last post by:
Hello all, am very frustrated because I can't get a simple table to display the same way in both browsers. It displays the way I want it to in Firefox but not in IE7 (Windows XP). 1) not sure if...
2
29520
by: =?Utf-8?B?R3JlZw==?= | last post by:
Is there a way to set the horizontal cell spacing or padding of a gridview without setting the vertical spacing/padding? I'd like to be able to put some space between the columns without putting...
0
7537
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...
1
7099
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
5685
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,...
0
4746
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3233
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3222
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1594
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
799
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
456
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.