search
HomeWeb Front-endHTML Tutorial【HTML】Table mark_html/css_WEB-ITnose

When designing web pages, tables are often used to organize page information. It can divide the web page into any number of rectangular areas. Each area can contain navigation, text, images, animations and other information. The designer can Place any web element into it.

1. Definition of table:

1) Insert pairs of

tags where tables need to be used, This will complete the insertion of the table. Commonly used tags for defining tables are

标签                                      

说明                                                    

表格标记,用于插入表格

行标记,用于插入行

列标记,用于插入列

表头标记,用于设置表头信息

表格标题,设置标题

tags                                                                                                                                       

Table title, set title
Table tag, used to insert tables
<html><head>	<title>表格的定义</title></head><body>	<table border="1">		<caption>计算机学习</caption>		<tr>			<th>CS</th>			<th>数据库</th>			<th>BS</th>		</tr>		<tr>			<td>软件工程</td>			<td>SQL Server</td>			<td>html</td>		</tr>		<tr>			<td>设计模式</td>			<td>mySql</td>			<td>JavaScript</td>		</tr>	</table></body></html>

Row tag, used to insert rows

Column tag, used to insert columns

标签                                      

说明                                                   

定义一组表头行

为表格添加一个标注

定义表格的主体部分

td>
Header tag, used to set header information
Example: Effect: 2) Divide the structure table Dividing the structure table means dividing a table into three parts, using three tags respectively td> Define the main part of the table
Tags                                                                                                                   >
Define a set of header rows
Add a label to the table

2. Table attributes

In the design of web pages, it is often necessary to make some formatting settings for the table

in the web page. These settings are completed by setting the table tag attributes. of.

Width of the table

属性名称

说明                                                                       

width

表格的宽度

border

边框粗细

frame(8种属性值)

设置表格的边框样式

属性值                        

说明                                           

void

不显示边框

border

显示上下左右边框

above

显示上边框

below

显示下边框

hsides

显示上下边框

lhs

显示左边框

rhs

显示右边框

vsides

显示左右边框

Attribute name
Description                       

width

属性值                        

说明                                           

all

显示所有内部边框

none

不显示内部边框

groups

显示介于行列边框

cols

仅显示列边框

rows

仅显示行边框

border Border thickness frame (8 attribute values) Set the border style of the table Attribute value                                                                                                       🎜> void Do not show borders border Show top, bottom, left and right borders above Show top border below Show bottom border hsides Show top and bottom borders lhs Show left border rhs Show right border vsides Show left and right border rules (5 attribute values) Set the inside of the table Border attributes
Attribute value             ; all Show all inner borders none No Show internal borders groups Show between row and column borders cols Show column borders only rows Show only row borders

实例:

<html><head>	<title>表格的属性</title></head><body>	<table width="500" frame="hsides" rules="rows">		<caption>计算机学习</caption>		<tr>			<th>CS</th>			<th>数据库</th>			<th>BS</th>		</tr>		<tr>			<td>设计模式</td>			<td>mySql</td>			<td>JavaScript</td>		</tr>		<tr>			<td>软件工程</td>			<td>SQL Server</td>			<td>html</td>		</tr>	</table></body></html>

效果:

3.表格行与单元格的属性

       在表格中,通过

标记的属性来设置表格中某一行的属性,用
的属性设置表格单元格的属性。

属性名称                                        

说明                                                                           

align(3种属性值)

设置行内容的水平对齐方式

属性值                                  

说明                             

left

左对齐

right

右对齐

center

居中对齐

 

valign(4种属性值)

设置行内容的垂直对齐方式

属性值                                  

说明                             

top

顶端对齐

middle

居中对齐

bottom

底部对齐

baseline

基线

rowspan

设置跨行,即单元格的纵向合并

colspan

设置跨列,即单元格的横向合并

实例:

<html><head>	<title>表格行与单元格的属性</title></head><body>	<table width="500" frame="hsides" rules="all">		<caption>计算机学习</caption>		<tr>			<th>CS</th>			<th>数据库</th>			<th>BS</th>		</tr>		<tr>			<td rowspan="2" align="center">设计模式</td>			<td >mySql</td>			<td>JavaScript</td>		</tr>		<tr>			<td>SQL Server</td>			<td>html</td>		</tr>	</table></body></html>

效果:

 

4.多个表格的使用

       表格可以嵌套使用以表示层次关系,在

标记插入表格后,可在间再插入
表示在单元格中插入表格;也可以多个同级表格同时使用,此时有两个常用的属性可方便表格的排版,美化布局。

cellspacing                                             

设置单元格的间距           

cellpadding

设置单元格中内容与边框之间的间距       

小结:

       表格是一种很简单的页面布局工具,它的应用使得网页简洁直观,且更便于阅读。熟练掌握主要的表格标记的相关属性,可以提高工作效率

Statement
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
What is the purpose of HTML attributes?What is the purpose of HTML attributes?May 07, 2025 am 12:01 AM

HTMLattributesareessentialforenhancingwebelements'functionalityandappearance.Theyaddinformationtodefinebehavior,appearance,andinteraction,makingwebsitesinteractive,responsive,andvisuallyappealing.Attributeslikesrc,href,class,type,anddisabledtransform

How do you create a list in HTML?How do you create a list in HTML?May 06, 2025 am 12:01 AM

TocreatealistinHTML,useforunorderedlistsandfororderedlists:1)Forunorderedlists,wrapitemsinanduseforeachitem,renderingasabulletedlist.2)Fororderedlists,useandfornumberedlists,customizablewiththetypeattributefordifferentnumberingstyles.

HTML in Action: Examples of Website StructureHTML in Action: Examples of Website StructureMay 05, 2025 am 12:03 AM

HTML is used to build websites with clear structure. 1) Use tags such as, and define the website structure. 2) Examples show the structure of blogs and e-commerce websites. 3) Avoid common mistakes such as incorrect label nesting. 4) Optimize performance by reducing HTTP requests and using semantic tags.

How do you insert an image into an HTML page?How do you insert an image into an HTML page?May 04, 2025 am 12:02 AM

ToinsertanimageintoanHTMLpage,usethetagwithsrcandaltattributes.1)UsealttextforaccessibilityandSEO.2)Implementsrcsetforresponsiveimages.3)Applylazyloadingwithloading="lazy"tooptimizeperformance.4)OptimizeimagesusingtoolslikeImageOptimtoreduc

HTML's Purpose: Enabling Web Browsers to Display ContentHTML's Purpose: Enabling Web Browsers to Display ContentMay 03, 2025 am 12:03 AM

The core purpose of HTML is to enable the browser to understand and display web content. 1. HTML defines the web page structure and content through tags, such as, to, etc. 2. HTML5 enhances multimedia support and introduces and tags. 3.HTML provides form elements to support user interaction. 4. Optimizing HTML code can improve web page performance, such as reducing HTTP requests and compressing HTML.

Why are HTML tags important for web development?Why are HTML tags important for web development?May 02, 2025 am 12:03 AM

HTMLtagsareessentialforwebdevelopmentastheystructureandenhancewebpages.1)Theydefinelayout,semantics,andinteractivity.2)SemantictagsimproveaccessibilityandSEO.3)Properuseoftagscanoptimizeperformanceandensurecross-browsercompatibility.

Explain the importance of using consistent coding style for HTML tags and attributes.Explain the importance of using consistent coding style for HTML tags and attributes.May 01, 2025 am 12:01 AM

A consistent HTML encoding style is important because it improves the readability, maintainability and efficiency of the code. 1) Use lowercase tags and attributes, 2) Keep consistent indentation, 3) Select and stick to single or double quotes, 4) Avoid mixing different styles in projects, 5) Use automation tools such as Prettier or ESLint to ensure consistency in styles.

How to implement multi-project carousel in Bootstrap 4?How to implement multi-project carousel in Bootstrap 4?Apr 30, 2025 pm 03:24 PM

Solution to implement multi-project carousel in Bootstrap4 Implementing multi-project carousel in Bootstrap4 is not an easy task. Although Bootstrap...

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)