0

I have read around css properties for tables but I fail to understand why I cannot set a fixed width for my parent table: it always gets overridden by css properties further downstream. e.g. my code below:

Any idea how I can set the table to width 200, and then get the text to wrap in the nested table? Right now all tables are stretching to accommodate lengthy text :-(

http://jsfiddle.net/8weav9qo/

<table cellspacing="0" cellpadding="0" border="1" width="200"> <tr width="100px"> <td> Title<br/><br/> <table cellspacing="4" cellpadding="0"><tr> <td><img src="http://www.macaulay.ac.uk/IFRU/images/blue_arrow.gif"></img></td> <td>HelloHelloHelloHelloHelloHelloHelloHelloHelloHello</td> </tr></table> <table cellspacing="4" cellpadding="0"><tr> <td><img src="http://www.macaulay.ac.uk/IFRU/images/blue_arrow.gif"></img></td> <td>Hello</td> </tr></table> <table cellspacing="4" cellpadding="0"><tr> <td><img src="http://www.macaulay.ac.uk/IFRU/images/blue_arrow.gif"></img></td> <td>Hello</td> </tr></table> </td> </tr> </table> 
3
  • Are you allowed to use divs instead of tables?, it will be easier to manipulate and better cross browser behavior. Commented Jul 8, 2015 at 16:50
  • tr doesn't have a width attribute. Commented Jul 8, 2015 at 16:56
  • You can try td {word-break: break-all;} Commented Jul 8, 2015 at 17:08

1 Answer 1

2

Just add table-layout: fixed - http://jsfiddle.net/8weav9qo/2/

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.