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

Posted on 2008-11-13
Last Modified: 2013-11-19

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.

Question by:vielkacarolina1239
    LVL 39

    Assisted Solution

    by:Pratima Pharande
    try this

    <table width="50%" border="1"  >
          <tr><td style="width:50%" >1</td>
    LVL 3

    Assisted Solution

    Use width="50%". It will set to 50% of the table width.
    <TABLE cellSpacing=1 cellPadding=1 width="100%" border=1>
        <TD width=50%>1</TD>

    Open in new window

    LVL 44

    Accepted Solution

    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.

    Featured Post

    Do You Know the 4 Main Threat Actor Types?

    Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

    Join & Write a Comment

    So you have coded your own WordPress plugin and now you want to allow users to upload images to a folder in the plugin folder rather than the default media location? Follow along and this article will show you how to do just that!
    Why do we like using grid based layouts in website design? Let's look at the live examples of websites and compare them to grid based WordPress themes.
    In this tutorial viewers will learn how to style different bullet points for unordered lists in CSS. Begin with a normal unordered list; the default bullet point is a solid circle: In the CSS, create a defined class of unordered list by typing "ul.S…
    The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

    729 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now