Min-width for table

Hi All,

This is first post here.

i have div with 50% width. and inside one table with 100%,

but div with not working. table going 100%

here is code.

<div style=“min-width:50%; background:#000; padding:50px;”>
<table width=“100%” border=“1” cellspacing=“0” cellpadding=“0” style=“background:#cfcfcf; height:800px;”>
<tr>
<td> </td>
</tr>
</table>
</div>

Take out the min-

You are telling the div it’s min width should be 50% but as it is block level it will expand to 100% unless you specifically tell it not to.

i.e.

<div style=“width:50%; background:#000; padding:50px;”>

Hi sidd. Welcome to SitePoint. :slight_smile:

As craig said, min-width only tells the div it is not allowed to have a width of less that 50% … but it can still have a width of 100%.

Hi sidd. Welcome to SitePoint.

Actually, I think he was meaning about applying with for the table. What exactly are you trying to get it to look like?
as was said before, putting min width doesnt actually set the width for your div, it only LIMITS how small it can be.
if you did apply width:50% to the div and the 100% width to the table the table will be 100% the div ( in other words the background color of the div wont show up. I am not sure if that what you want… it just doesnt make sense.

if you put the div there to give the table width then actually you don’t need it at all. again it depends on what you are trying to accomplish.