6

I've created cells for a dynamic table in html page using "document.createElement('td')" method & now wish to set width of each individual cell with some different value. Tried "cell.width = width" but it didn't work.

how can I achieve it?

4
  • 3
    cell.style.width = width? Welcome to SO! Commented Jan 18, 2013 at 9:01
  • you want to change the width of the cell from the other corresponding cells in the table. Commented Jan 18, 2013 at 9:02
  • @SHANK: no... actaully I'm adding cells to table dyanamically using some function in javascript & wish to add some code to set individual cell width right after I add a cell. :) Commented Jan 18, 2013 at 9:12
  • @11684: many thnx...... it workd... Commented Jan 18, 2013 at 9:49

2 Answers 2

12

Use style.width:

var cell = document.createElement('td');
parent.appendChild(cell);
cell.style.width = '200px';

Here is an example.

Sign up to request clarification or add additional context in comments.

2 Comments

Click on the oldest tab :-)
Anyway, if +1 is so important here is one by me. Best regards! :-)
6

To post my comment as an answer:

Use cell.style.width = width;.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.