Table Widths; I have got completely lost

The web page concerned is here http://www.c5d.co.uk/1939NTIBHigherHurst&Greenhurst.php

What I want is all the columns to line up under each other with the secondary table inserted. Effectively as if pages were laid out in vertically, Probably it’s easy to view rather than explain.

I understaood that I could give the columns in the main table ids and set percentages so that they each table would line up with all the columns running in a straight line but it it’s not happening

Have I done it wrong? Or have I misundersttood?

Antony

Hi @certificates Yes, the only way to get all your table columns to line up would be to give every column a width. As you have found out tables are not easy to work with.

Hi, Antony.

Unfortunately, your understanding of tables and IDs needs to be touched up a bit.

What you see in your browser is normal table behavior in which the content of the cells attempts to fit within the width of the table. This means that the actual widths of the cells may vary from the value that you assign.

Because you want the same width properties to be assigned to specific tables, classNames would be appropriate. IDs would be a waste… and in this case, they do not convey consistent widths as you believe they do.

I want to test a sample of your layout before I make any recommendations.

I’ll post again later.

1 Like

No problem

As always you’re very helpful At least I got the two different types of table to work OK!

The good news is that this issue has a solution.

The concept is simple enough… the columns in a continuous table will be the same width from top to bottom.
The problem with your layout is that the table is not continuous. The page is made up of a number of tables stacked together.
.
The solution is to make the outer table continuous by putting those odd tables into a row within the main table as nested tables, like this:

    <tr>
      <td colspan="12">  <!-- NOTE colspan here -->
        <table class="thirtynineheader">
          <tr>
            <td>ED Letter Code</td>
            <td>NTIB</td>
            <td>Borough, U.D. or R.D.</td>
            <td>Ashton U Lyne</td>
            <td>Registration District<br>and Sub District</td>
            <td>468/2</td>
          </tr>
        </table>
      </td>
    </tr>

The main table is className “table1939”; there should only be ONE of these tables. The “odd” tables that presently interrupt the main table have className “thirtynineheader”. They should be added to a row within the main table. The table-cell in that row should be given the attribute colspan=“12” so the nested table can expand to the full width of the parent table.

Please copy this file to your PC and open it in your browser. When you look at the code in your editor, please notice how little CSS is required to create this layout. No IDs, no columns, not much of anything.

(The lines in my example were taken from varous locations within your file and do not necessarily group together.)

cell-width-continuity.html (7.5 KB)

 
The bad news is that you are repeating some errors in your CSS that should have been resolved three years or ago.

#table-7 tr, th, td {-moz-border-bottom-colors: none;}
#table-4 tr, th, td {-moz-border-bottom-colors: none;}
.table-6 td, th, td {border: 1px solid black;}
.table-5 td, th, td {border: 1px solid black;}
.table-2 td, th, td {border: 1px solid black;}
#table-3 tr, th, td {-moz-border-bottom-colors: none;}
...

Most td and th elements are being targeted globally, not specifically. I grabbed a few lines to illustrate the problem.

That first line above actually says:

#table-7 tr {-moz-border-bottom-colors: none;}
th {-moz-border-bottom-colors: none;}
td {-moz-border-bottom-colors: none;}

The “tr” is being addressed specifically, but the “th” and “td” are being addressed globally.

If you wanted to address the th and td elements within a specific parent element (table), you should address them in this manner:

#table-7 tr, #table-7 th, #table-7 td {...}

 
I would imagine that you can get rid of the IDs in your code that were added in error.

Hope this is helpful.

1 Like

As always thanks very much. I wouldn’t have thought of nesting the tables but it works perfectly

With regard to the #table-7 etc, I have never touched them since the day that you provided that CSS to me!

On that css sheet Rows 22-25 is supposed to control the width of the table on this page http://www.c5d.co.uk/description1871ed1.php but some of the other stuff is so old, I don’t know what it styles

That’s why I just leave it alone

Thanks

Antony

I’ll have to disagree with you about the source of those IDs and that CSS arrangement. I am ID averse and would not have written that. In fact, these are the comments that I included near the top of one of the CSS files that I sent to you dated Jan 2014.

/*
   {border-collapse:collapse;} can be applied to a <table> only, NOT to <tr>, <th>, or <td>
THIS LINE...
   #table-23 tr,th,td {border-collapse:collapse; border:0px solid black;border-style:hidden;border-bottom-color:#708090;text-align:center;}
IS THE SAME AS THESE THREE LINES...
   #table-23 tr {border-collapse:collapse; border:0px solid black;border-style:hidden;border-bottom-color:#708090;text-align:center;}
   th {border-collapse:collapse; border:0px solid black;border-style:hidden;border-bottom-color:#708090;text-align:center;}
   td {border-collapse:collapse; border:0px solid black;border-style:hidden;border-bottom-color:#708090;text-align:center;}
REALIZE that none of these properties apply to a "tr" tag, so the first line, #table-23 tr {...}, is wasted.
NOTICE that the "th" and "td" selectors target ALL "th" and "td" selectors on the entire page, and are being overridden by the last "th" or "td" selector on the page.  The CASCADE in CSS.
To target only the "th" and "td" selectors in #table-23, write #table-23 th, #table-23 td {...}
*/

table {margin:auto;font-size: 15px;font-style:italic; font-weight:bold;}
td{font-weight:bold; font-style:italic;}
#table-23 {border-collapse:collapse; border:0px solid black;border-style:hidden;}
#table-23 tr,th,td  {border-collapse:collapse; border:0px solid black;border-style:hidden;border-bottom-color:#708090;text-align:center;}
#table-3 {border-collapse:collapse; border:0px solid black;border-style:hidden;}
#table-3 tr,th,td  {border-collapse:collapse; border:0px solid black;border-style:hidden;border-bottom-color:#708090;text-align:center;}
.table-2 td,th,td {border: 1px solid black;}
.table-2 {margin-bottom: 10px; padding-bottom: 10px; border-bottom: 2px solid #000;}
.table-2 th {height:25px; } 
#Row1 {width: 15%;}
#Row2 {width: 50%;}
#Row3 {width: 15%;}

And those #Rows are actually cells/columns. Definitely not my doin’s.

You can use a utility such as “DustMeSelectors” to find out if any of those CSS styles are not being used. It might help you trim some of the waste from your CSS. Efficiency is always a good thing.

Cheers, Antony

I have tried to use the Dustme tool but it only tells me what’s not being used on the page I am on.

It doesn’t say if the CSS is being utilised by another page which is what I need really

Thanks for the tip though.

I know things need thinning out, but when you don’t know whats live and what isn’t I’m a bit stummoed

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.