Jump to content

Max-width for tables?


Michdd

Recommended Posts

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.