html spacing inside the table

99封情书 提交于 2019-12-12 01:25:54

问题


how can i increase the space in this table "Row 1, cell 1"?

 <html>
 <table border="1">
 <tr>
 <td>Row 1, cell 1</td>
 <td>Row 1, cell 2</td>
 </tr>
 </table>  
 </html>

pls check here for the image: http://img227.imageshack.us/img227/6166/htmln.png

is this correct:

 <table border="1" td.my-cell { padding:100px; }>
<tr>
<td class="my-cell">Row 1, cell 1</td>
<td>Row 1, cell 2</td>
</tr>
</table>  

回答1:


You can either use cellpadding or using css

.cellpadding {
   padding-left: 5px;
   padding-right: 5px;
}

<td class="cellpadding">Row 1, cell 1</td>

EDIT Your edited post is wrong....do this:

<table border="1">
    <tr>
        <td style="padding-left: 5px; padding-right: 5px;">Row 1, cell 1</td>
        <td>Row 1, cell 2</td>
    </tr>
</table>



回答2:


You can add a class to that specific cell and then use that class-name to apply css:

.larger {
height: 2em;
width: 4em;
padding: 2em;
}

<!-- rest of table -->
<td class="larger">Row 1, cell 1</td>
<!-- rest of table -->

Or you could use specific style-rules to apply a particular style:

tr td:first-child /* selects the first td within a tr */

Though this would apply to the first td of every row.




回答3:


elaborate on "space"? you can add padding to the td if thats what you mean by "space"

table td { padding:5px; }

if you just want that cell bigger, add a calss

table td.my-cell { padding:5px; }

<td class="my-cell">Row 1, cell 1</td>

or do you mean

<td>Row 1,           cell1</td>

you can increase the space between words like this:

table td { word-spacing: 20px; /* adjust */ }



来源:https://stackoverflow.com/questions/3871237/html-spacing-inside-the-table

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!