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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.