HTML basic tutorial table tag
Table tag
##The web page has functions similar to those in word. Of course, there will also be functions similar to those in excel, and table is one of them
The structure of the table
Width: Table width, the unit can be a percentage or a fixed value.
Height: Table height. Align: horizontal alignment of the table, values: left, center, right
Border: border thickness.
Bordercolor: Border color.
bgColor: table background color.
background: background image URL.
cellpadding: the distance between the cell edge and the content (padding distance)
cellspacing: the distance between cells ( spacing)
rules: merge cell border lines, value: all
- Note: rules compatibility is not good, please Use CSS to replace it.
- Let’s actually draw a table
<!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> </head> <body> <table border="2" width="300" height="100" bordercolor="blue" bgColor="#88cc66" cellspacing="0" cellpadding="2" rules="all"> <tr> <td>工号</td> <td>姓名</td> <td>职位</td> </tr> <tr> <td>001</td> <td>小明</td> <td>设计师</td> </tr> <tr> <td>002</td> <td>小方</td> <td>工程师</td> </tr> <tr> <td>003</td> <td>小白</td> <td>程序员</td> </tr> </table> </body> </html>
- ## <tr>Attributes—Row tag
bgColor: Row background color
height: Row height
align: The text in the row is horizontally centered, values: left, center, right
valign: Vertically centered, values: top, middle, bottom
##<td>or<th>attribute
< td> is an ordinary cell, <th> is a header cell, which is displayed in bold and centered.
- width: cell width
- height: cell height
- bgColor : Cell background color
- background: Cell background image
- align: Horizontal alignment
- valign: Vertical horizontal alignment
- rowspan: Merge upper and lower cells. Merge attributes must be placed in the first cell.
- colspan: merge left and right cells. When merging, there must be decreases as well as increases, ensuring that the number of cells in each row remains unchanged.
<!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> </head> <body> <table border="2" width="400" height="100" bordercolor="blue" bgColor="#88cc66" cellspacing="0" cellpadding="2" rules="all"> <tr bgColor="red" align="center"> <th>星期日</th> <th>星期一</th> <th>星期二</th> <th>星期三</th> <th>星期四</th> <th>星期五</th> <th>星期六</th> </tr> <tr bgColor="yellow" align="center"> <td height="50">25</td> <td>26</td> <td>27</td> <td>28</td> <td>29</td> <td>30</td> <td>1</td> </tr> <tr align="center"> <td height="50">2</td> <td>3</td> <td>4</td> <td>5</td> <td>6</td> <td>7</td> <td>8</td> </tr> </table> </body> </html>
Note: The attribute is case-sensitive. If bgColor is written as bgcolor, it will have no effect
You can enter each attribute and view the output effect
##caption tag
Summary
The content of the summary will not be displayed in the browser. Its function is to increase the readability (semanticization) of the table, enable search engines to better understand the table content, and also enable screen readers to better help special users read the table content.
Syntax: <table summary="table introduction text">Title
is used to describe the content of the table , the display position of the title: above the table.
Grammar:
<table> <caption>Title text</caption>
<tr> <td>…</td>
<!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> </head> <body> <table border="2" width="400" height="100" bordercolor="blue" bgColor="#88cc66" cellspacing="0" cellpadding="2" rules="all"summary="日历信息"> <caption>2016.10日历</caption> <tr bgColor="red" align="center"> <th>星期日</th> <th>星期一</th> <th>星期二</th> <th>星期三</th> <th>星期四</th> <th>星期五</th> <th>星期六</th> </tr> <tr bgColor="yellow" align="center"> <td height="50">25</td> <td>26</td> <td>27</td> <td>28</td> <td>29</td> <td>30</td> <td>1</td> </tr> <tr align="center"> <td height="50">2</td> <td>3</td> <td>4</td> <td>5</td> <td>6</td> <td>7</td> <td>8</td> </tr> </table> </body> </html>
Continuing Learning
- Course Recommendations
- Courseware download
-
ElementaryHTML+CSS basic introductory tutorial
82608 people are watching -
ElementaryHTML/CSS 5-hour basic introductory tutorial
26360 people are watching -
ElementaryCSS 0 basic introductory tutorial
24383 people are watching -
ElementaryJQuery basic introductory tutorial
41315 people are watching -
ElementaryPython basic introductory tutorial
128805 people are watching -
ElementaryEasyUI basic introductory video tutorial
17401 people are watching -
ElementaryNginx basic introductory video tutorial
24834 people are watching -
ElementaryHTML5 basic knowledge introductory video tutorial
10915 people are watching -
Elementary0 Basic WeChat development introductory video tutorial
11649 people are watching -
ElementaryHTML basic tutorial
31757 people are watching -
ElementaryHan Shunping 2016 latest HTML basic video tutorial
10567 people are watching -
ElementaryBasic knowledge of HTML+css
22337 people are watching
Students who have watched this course are also learning
- Let's briefly talk about starting a business in PHP
- Quick introduction to web front-end development
- Large-scale practical Tianlongbabu development of Mini version MVC framework imitating the encyclopedia website of embarrassing things
- Getting Started with PHP Practical Development: PHP Quick Creation [Small Business Forum]
- Login verification and classic message board
- Computer network knowledge collection
- Quick Start Node.JS Full Version
- The front-end course that understands you best: HTML5/CSS3/ES6/NPM/Vue/...[Original]
- Write your own PHP MVC framework (40 chapters in depth/big details/must read for newbies to advance)