How to limit a table cell to one line of text using CSS?

左心房为你撑大大i 提交于 2019-11-30 10:46:23

overflow will only work if it knows where to start considering it overflown. You need to set the width and height attribute of the <td>

TAKE 2

Try adding table-layout: fixed; width:500px; to the table's style.

UPDATE 3

confirmed this worked: http://jsfiddle.net/e3Eqn/

Add the following to your stylesheet:

table { white-space: nowrap; }

cm2

Add the following to your stylesheet:

table{
     width: 500px; table-layout:fixed;
}

You need to add the table width to ensure that the next property will fit the elements to the specified size. The table-layout property here forces the browser to use a fixed layout within the 500 pixels it's given.

  <table border="1" style="width:200px">
<tr>
    <td>Column 1</td><td>Column 2</td>
</tr>
<tr>
   <td nowrap="nowrap">
    
		Single line cell just do it</td>
   <td>
	
		multiple lines here just do it</div></td>
</tr>
</table>

Simple And Useful. use above code for

Souleymane Atto Deba

<table border="1" style="width:200px">
  <tr>
    <td>Column 1</td>
    <td>Column 2</td>
  </tr>
  <tr>
    <td nowrap="nowrap">Single line cell just do it</td>
    <td>multiple lines here just do it</td>
  </tr>
</table>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!