Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8739823
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T11:01:01+00:00 2026-06-13T11:01:01+00:00

HTML table ignoring element-style width I have an HTML table where certain cells have

  • 0

HTML table ignoring element-style width

I have an HTML table where certain cells have very long text contents.

I want to specify a width (in pixels) for these cells using jQuery, but the rendered table just ignores the given width.

Is there any way to force the table to respect this width?

Thanks!


JSFiddle: http://jsfiddle.net/sangil/6hejy/35/

(If you inspect the cell you can see the the computed width is different than the element-style width)


HTML:

<div id="tblcont" class="tblcont">
 <table id="pivot_table">
 <tbody>
   <tr>
      <th id="h0" >product</th>
      <th id="h1" >price</th>
      <th id="h2" >change</th>
   </tr>         
   <tr>
      <!-- this is the cell causing trouble -->
      <td id="c00" >Acer 2400 aaaaaaaaaaaaaaaaaaaaaaaaaa</td>
      <td id="c01" >3212</td>
      <td id="c02" >219</td>         

   </tr>
   <tr>
      <td id="c10" >Acer</td>
      <td id="c11" >3821</td>
      <td id="c12" >206</td>         

   </tr>
</tbody>
</table>
</div>

CSS:

.tblcont {
  overflow: hidden;
  width: 500px;
}

table {
  table-layout: fixed;
  border-collapse: collapse; 
  overflow-x: scroll; 
  border-spacing:0; 
  width: 100%;
}

th, td {
 overflow: hidden;
 text-overflow: ellipsis;
 word-wrap: break-word;
}

th {
 height: 50px;
}

​Javascript:

$(document).ready(function() {

  // THIS LINE HAS NO EFFECT!
  $('#c00').width(30);
});​
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T11:01:03+00:00Added an answer on June 13, 2026 at 11:01 am

    I can see from your fiddle that you already have a good grasp on how to get the word truncation and such in-place. I think you may find it useful to do something like the following:

    <table>
      <colgroup>
        <col style="width: 30px;" /> <!-- this style affects the whole 1st column -->
        <col />
        <col />
      </colgroup>
    
      <!-- the rest of your table here -->
    </table>
    

    This method works with the HTML specification in a way that is compliant – and will resize the whole column. If you instead change the display of the cell to inline-block, as mentioned above, what will happen is that you take the cell out of the table’s flow – and other stylistic changes may cease working.

    By styling the entire col using the code above, you use the table element’s table-layout: fixed styling to your advantage instead.

    Additionally – I noticed that you have the cells set up to use text-overflow: ellipsis; Check out this article on quirksmode to understand why it’s not working. The fix you need is to make the following edit:

    th, td {
        border: solid #4682B4 1px;
        overflow: hidden;
        text-overflow: ellipsis;
        word-wrap: break-word;
        text-align: center;
    
        white-space: nowrap; /* Add this line */
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following HTML table format: <table style=width: 100%;> <tr> <td> //How to
I have the following html table <table id={64ED3A94-5833-4CC7-869F-CCE583B498BE} class=ms-listviewtable width=100% cellspacing=0 cellpadding=1 border=0 xmlns:o=urn:schemas-microsoft-com:office:office
I have an HTML table in my jsp page. This conains text fields and
I have table [HTML Table] on page I want to delete record from table
I have the following HTML table and want to replace the subtable class =
I have a HTML table which is inside of a div element and I
I have an HTML table and I'd like the contents of one cell (
I have an HTML table full of text fields. I have the ability to
I have a html table and I want to freeze the header row th
I have an HTML table with a link in the first column. I want

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.