Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to align table columns of two tables 2

Status
Not open for further replies.

heeeep72

Programmer
Dec 15, 2004
33
CH
Hi, i have the following problem:

I have two tables on my html page (one of them is below the other one). None of them has fixed column widths. Even if so, I want their columns to align with each other. I use CSS in my page, and i am totally unexperienced with that. Can I solve this problem without setting fixed column widths? (i had only one idea: i should put a line into both of them (same line into both of the tables), and make this line invisible in (at least one of) the tables). Is this a good idea? If yes, how to realize it? If this is no good solution, is there an other way to solve this? This would be very urgent for me. Can you give an idea how to make it?

Thx a lot!
heeeep
 
Thank you for your answer, but this is not possible, because I put them into two different tables on purpose. Namely: the second table is in a <div>. (i want to switch the second table on/off visible/invisible) See my earlier posting titled: "jsp and javascript" in the javascript forum. So I need an other solution... :(

heeeep
 
Took some playing around with search, but I found this thread again: thread215-1016957

I posted some javascript code there on how to make tables have the same column widths. It works, but:

It may not be compatible with any browser other than IE (that wasn't a requirement, so I didn't test it);

If the user resizes their browser window, it messes up the layout again.

There's other solutions recommended as well.


Tracy Dryden

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard. [dragon]
 
What you mentioned does not constitute usage of two tables. You can set classes or ids to certain rows and just control display of table rows rather then all the table.
 
Thanks to both of you,

Vragabond you are right i can control individual rows. Even if so, the biggest problem is that it destroys my design (column widths are changing like the wind). ...So I have to use fixed column widths at the end... Can I set it once for a whole table column, or I have to set it for each table cell individually?

thx,
heeeep
 
You only have to set the widths of the columns in one row, frequently the header row. The rest of the rows will follow along.


Tracy Dryden

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard. [dragon]
 
Since all the cells in a column have to be the same width (that is how tables work) it should be enough to specify the widths once in the header row. As an alternative, you can use the col attributes to set the columns up ahead. Technique is explained in this FAQ:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top