Michdd Posted October 26, 2008 Share Posted October 26, 2008 In CSS how do a set a max-width for my <tr> (table) Link to comment https://forums.phpfreaks.com/topic/130146-max-width-for-tables/ Share on other sites More sharing options...
kevin777 Posted October 26, 2008 Share Posted October 26, 2008 I'm not sure if this works, but can you just add a class to the TD and then use the regular css 'max-width=xx' i.e. td.classname{max-width:500px;} If this wont work can you add a div inside the TD and give the div a max width? like this: css: table tr div.stylename{max-width:500px;} html: <table border="1"> <tr> <div class="stylename"> <td>row 1, cell 1</td> <td>row 1, cell 2</td> </div> </tr> <tr> <div class="stylename"> <td>row 2, cell 1</td> <td>row 2, cell 2</td> </div> </tr> </table> Maybe another way could be to use php, as in set the width of the TD to a php variable which is connect to a max width setting ? Goodluck Link to comment https://forums.phpfreaks.com/topic/130146-max-width-for-tables/#findComment-674995 Share on other sites More sharing options...
dropfaith Posted October 26, 2008 Share Posted October 26, 2008 Wont validate as theres elements other then td or th in a tr tag <table border="1"> <tr> <div class="stylename"> <td>row 1, cell 1</td> <td>row 1, cell 2</td> </div> </tr> <tr> <div class="stylename"> <td>row 2, cell 1</td> <td>row 2, cell 2</td> </div> </tr> </table> Will Validate <table> <tr> <td> <div class="stylename"> <table> <tr> <td>row 1, cell 1</td> <td>row 1, cell 2</td> </tr> </table> </div> </tr> </table> Link to comment https://forums.phpfreaks.com/topic/130146-max-width-for-tables/#findComment-675137 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.