Home > Web Front-end > HTML Tutorial > How to set the width of html td

How to set the width of html td

青灯夜游
Release: 2023-01-06 11:13:19
Original
22183 people have browsed it

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.

How to set the width of html td

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>
Copy after login

Rendering:

How to set the width of html td

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>
Copy after login

Rendering:

How to set the width of html td

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template