how to fix the width of td element to 50%?

Hi,

I need to fix the width of a td element. I have used <td style="width:50%; min-width:50%;"></td>
but the width is not 50%. How can I accomplish this task.

Thanks,
vielkacarolina1239Asked:
Who is Participating?
 
scrathcyboyConnect With a Mentor Commented:
You can't use relative % widths this way in tables like you can in DIVs and tableless layout.  If you specify the width of the TABLE as a fixed value, like 500 px, then you can use TD width 50%, but that is the same as giving it 250px fixed.  If the table is percent width, and the TDs are also percents, they will only adjust to the width of the data in them, they will not CUT OFF or force wrap data in the TDs.  You need to be using DIVs and SPANs for what you want -- an absolute width, no matter what the length of the data in it.
0
 
Pratima PharandeConnect With a Mentor Commented:
try this

<table width="50%" border="1"  >
      <tr><td style="width:50%" >1</td>
      </tr>
      </table>
0
 
SreejithGConnect With a Mentor Commented:
Use width="50%". It will set to 50% of the table width.
<TABLE cellSpacing=1 cellPadding=1 width="100%" border=1>
  <TR>
    <TD width=50%>1</TD>
    <TD>1</TD>
  </TR>
  <TR>
    <TD>1</TD>
    <TD>1</TD>
  </TR>
  <TR>
    <TD>1</TD>
    <TD>1</TD>
  </TR>
 </TABLE>

Open in new window

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.