html How to set the width of td: 1. Directly use the width attribute of the td tag, the syntax format is "
"; 2. In the td tag Use the style attribute to add the "width: width value;" style.
The operating environment of this tutorial: Windows 7 system, CSS3&&HTML5 version, Dell G3 computer.
1. Directly use the width attribute of the td tag
The width attribute specifies the width of the table cell.
Generally, the space occupied by a cell is the space required to display its content. The width attribute is used to set a predefined width for the cell.
Example:
<table border="1"> <tr> <td width="100">商品</td> <td>价格</td> </tr> <tr> <td>T恤</td> <td>¥100</td> </tr> <tr> <td>牛仔褂</td> <td>¥250</td> </tr> <tr> <td>牛仔库</td> <td>¥150</td> </tr> </table>
Rendering:
2. Use the style attribute to add " width: width value; "Style
The style attribute specifies the inline style of the element.
Example:
<table border="1"> <tr> <td>商品</td> <td style="width: 100px;">价格</td> </tr> <tr> <td>T恤</td> <td>¥100</td> </tr> <tr> <td>牛仔褂</td> <td>¥250</td> </tr> <tr> <td>牛仔库</td> <td>¥150</td> </tr> </table>
Rendering:
Recommended tutorial: "html video tutorial"
The above is the detailed content of How to set the width of html td. For more information, please follow other related articles on the PHP Chinese website!