• Controlling width of tables using styles
    3 replies, posted
Hi there :) Sorry for the sort of confusing thread title, I was unsure as of what to call it. I have a little problem concerning some webprogramming. I am receiving 10 columns of data from a database and I want to insert these into some tables (if this is a bad way to do it, recommendations are gladly accepted!). This is fairly straightforward. But my problem is that some of the information I get have very long date strings (Example: 07:29:04--04-01-2010) and this breaks the standard table that I have. I read somewhere that using "width" is deprecated and instead I should use styles. Can someone explain how exactly I do this? Thanks in advance :)
Could always just embed the style. Just copied a table example from W3 and put in the style command. [code] <table> <tr> <th style="width:200px;">Firstname</th> <th>Lastname</th> <th>Savings</th> </tr> <tr> <td>Peter</td> <td>Griffin</td> <td>$100</td> </tr> <tr> <td>Lois</td> <td>Griffin</td> <td>$150</td> </tr> <tr> <td>Joe</td> <td>Swanson</td> <td>$300</td> </tr> <tr> <td>Cleveland</td> <td>Brown</td> <td>$250</td> </tr> </table>[/code] So the first table's width is modified by the embedded style. Just do style="CSS goes here" and be sure to use the : and ;'s.
or you could specify it globally [code] <html> <head> <style> .tableClassHeadOne { width: 300px; } .tableClassOne { width: 500px; } #datatable tr th { width: 600px; } </style> </head> <body> <table id="datatable"> <tr> <th class="tableClassHeadOne">Firstname</th> <th>Lastname</th> <th>Savings</th> </tr> <tr class="tableClassOne"> <td>Peter</td> <td>Griffin</td> <td>$100</td> </tr> <tr> <td>Lois</td> <td>Griffin</td> <td>$150</td> </tr> <tr> <td>Joe</td> <td>Swanson</td> <td>$300</td> </tr> <tr> <td>Cleveland</td> <td>Brown</td> <td>$250</td> </tr> </table> </body> </html> [/code]
Thanks a lot both of you :)
Sorry, you need to Log In to post a reply to this thread.