[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1145
  • Last Modified:

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,
0
vielkacarolina1239
Asked:
vielkacarolina1239
3 Solutions
 
Pratima PharandeCommented:
try this

<table width="50%" border="1"  >
      <tr><td style="width:50%" >1</td>
      </tr>
      </table>
0
 
SreejithGCommented:
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
 
scrathcyboyCommented:
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

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now