HTML Markup Language - Table Markup_HTML/Xhtml_Web Page Production
Standardized Design Solutions - Markup Language and Style Handbook Boston Red Sox World Series Championships< ;/p>
Web Standards Solutions The Markup and Style Handbook
Part 1: Get Down With Markup Starting from Markup Syntax
Chapter2 Evil form?
Did you know that when did using tables become a sinful act? Indeed, the biggest myth about writing web pages based on web standards is "Don't use tables anymore, ever!" Listen Forms must be avoided like the plague, must be sealed and thrown into dusty cabinets, and preserved as antiques passed down from the early days of the Internet.
Where does such disgust come from? Maybe in the beginning. Very simple, at least there is a good reason. Many people will confidently promote the benefits of abandoning the traditional layout of nested tables and fill-in-the-blank GIF images, and switching to the flexible and structured CSS layout. We may start to peel off the cocoon. Get rid of all the tables, and even start to stubbornly insist on expelling all the tables - regardless of the occasion.
We will see the CSS layout method and all the benefits of doing so later in the book. But for now we still Let’s first look at how to use tables in the right context—that is, when labeling data lists. We’ll look at a few simple ways to make our data lists easier to use and more beautiful.
That’s it Table
There is absolutely no reason not to use the table tag when labeling list data. But wait, what is list data? Here are some examples:
calendar
spreadsheet
Chart
Time Schedule
For these examples and many other cases, very complex and strict CSS effects must be used to make the data look like a table. Perhaps you can imagine what you get after using clever CSS floats and positioning all the items. The incompatible and contradictory results, not to mention that without CSS, accurately reading every piece of information would probably become an impossible task. In fact, we don’t have to be afraid of tables—we should use them for the purpose for which they were designed.
Forms for everyone
One of the reasons forms are reviled is because they have usability flaws if not used with care. For example: screen readers have trouble reading the content correctly, and Small screen devices are often disrupted by tables used for layout, but we have some simple ways to increase the usability of list data tables. At the same time, create a flexible structure for future styling with CSS.
Let’s take a look at Figure 3- A simple example from 1, this is the league record of the American League:
Figure 3-1: Typical data table example
Perhaps this is very depressing for Red Sox fans Statistical data, but Figure 3-1 is a perfect example of list data. It has three table headers (year, opponent, season record (w-l)), followed by four years of data. Above the table is the table title, description The content of the table.
The way to mark this data table is very intuitive. We may complete the work with code like this:
Year
Opponent
Season Record (W-L)< ;/td>
1918
Chicago Cubs
1916
Brooklyn Robins
91-63
1915
Philadelphia Phillies td>
101-50
1912
New York Giants
105-47
The results displayed in this way should be the same as the picture 3-1 is very similar, but we can add some improvements on this basis.
First, we can use a more semantic
It seems that it makes it easier for users to see the theme of the table, and it can also help Someone who knows the content of the page in some other way.
Let’s take out the paragraph at the beginning and add the correct
Year | Opponent | Season Record (W-L) |
1918 | Chicago Cubs | 75-51 |
1916 | Brooklyn Robins | 91-63 |
1915 | Philadelphia Phillies | 101-50 |
1912 | New York Giants | 105-47 |
重要的是,标题必须快速传达后面资料的主题,根据默认设置,大多数可视化浏览器将
#p#
加上摘要
另外,我们也能为
Year | Opponent | Season Record (W-L) |
1918 | Chicago Cubs | 75-51 |
1916 | Brooklyn Robins | 91-63 |
1915 | Philadelphia Phillies | 101-50 |
1912 | New York Giants | 105-47 |
表格的表头
在建立数据表格时,善用表头是件很重要的工作.在标记重要单元格时,我们可以发挥
可视化浏览器或许会以粗体居中的效果显示
除显示效果的优势外,使用
示例表格中的表头是最上面的那一行: Year,Opponent和Season Record(W-L).我们来把刚才的显示效果标签替换成正确的表头标签:
Year | Opponent | Season Record (W-L) |
---|---|---|
1918 |
Chicago Cubs | 75-51 |
Brooklyn Robins | 91-63 | |
1915 | Philadelphia Phillies | 101-50 | 1912 | New York Giants | 105-47 |
Using the
We don’t have to use additional display effect tags to highlight the header outside the data content.
According to the default settings, most visual browsers will display the content in the
Since it is relatively independent from the
We will continue to discuss other benefits of using the table header tag in the following chapters. .
#p#
The relationship between header and data
We can use the headers attribute to associate the header with the data in the corresponding
We continue to use the Red Sox record table as an example to demonstrate how to use it. First, we need to add a unique id to each
Year | Opponent | Season Record (W-L) | 1918 | Chicago Cubs | 75-51 |
---|---|---|
1915 | Philadelphia Phillies | 101-50 |
1912 | New York Giants | 105- 47 |
We choose a short and descriptive name for each header id, and then we give each data Add appropriate headers attributes to the cell so that the content matches the correct header id:
Year | Opponent | Season Record (W-L) |
---|---|---|
Chicago Cubs | 75-51 td> |
|
1916 | Brooklyn Robins< ;/td> |
91-63 |
1915 | Philadelphia Phillies | 101-50 |
1912 | New York Giants | 105-47 |
After establishing the correspondence between the table header and the content, the screen reader It is possible to read out each row of the table in this way: "Year: 1918, Opponent: Chicago Cubs, Season Record (W-L): 75-51". Compared with reading out the contents of each cell from left to right, This makes a lot more sense.
Letting each
#p#
Use the abbr attribute
In the previous example, you may feel that the "Season Record (W-L)" in the header is too long to pronounce using a speech synthesizer. At this time, as long as we add the abbr attribute, we can shorten the pronunciation content while retaining the original text in the
Year | Opponent | Season Record ( W-L) |
---|---|---|
1918 | Chicago Cubs | 75-51 |
1916 | Brooklyn Robins | > ;91-63 |
1915 | Philadelphia Phillies | 101-50 |
1912 | 105-47 |
We added abbr="Record", the screen reader will read "Record" using the short version of the header. >Here I would also like to mention three table-related tags. They not only provide more precise semantics for the table structure, but also provide additional tags for css, so that you do not need to use There are so many classes in tag design.
Quote from a W3C description of these tags in the HTML4.01 specification (http://www.php.cn/):Quote:
Table rows can be divided into table headers, table footers and an unlimited number of table bodies using thead, tfoot and tbody tags. This classification method allows the browser to support the function of independently scrolling the table body. When printing long tables , the header and footer can also be repeated on every page containing table data.
Therefore, using this classification method can also make it easier for browser users who support independent table bodies to read the table Content, especially long tables. and
cell: th, td { border- right: 1px solid #999; border-bottom: 1px solid #999; } Only adding borders on both sides is to create borders with the same width everywhere while making most of them pop. The key is that the browser can display it correctly. If I add a border on all sides, the top and left sides of the border will cause overlap when the cells are arranged. In a later example, I will give a way to use only one The border rule is a way to achieve the childlike effect. You will find that the entire table in Figure 3-2 is only missing the top and left borders. In order to complete the border, we add styles to the
|

Self-closingtagsinHTMLandXMLaretagsthatclosethemselveswithoutneedingaseparateclosingtag,simplifyingmarkupstructureandenhancingcodingefficiency.1)TheyareessentialinXMLforelementswithoutcontent,ensuringwell-formeddocuments.2)InHTML5,usageisflexiblebutr

To build a website with powerful functions and good user experience, HTML alone is not enough. The following technology is also required: JavaScript gives web page dynamic and interactiveness, and real-time changes are achieved by operating DOM. CSS is responsible for the style and layout of the web page to improve aesthetics and user experience. Modern frameworks and libraries such as React, Vue.js and Angular improve development efficiency and code organization structure.

Boolean attributes are special attributes in HTML that are activated without a value. 1. The Boolean attribute controls the behavior of the element by whether it exists or not, such as disabled disable the input box. 2.Their working principle is to change element behavior according to the existence of attributes when the browser parses. 3. The basic usage is to directly add attributes, and the advanced usage can be dynamically controlled through JavaScript. 4. Common mistakes are mistakenly thinking that values need to be set, and the correct writing method should be concise. 5. The best practice is to keep the code concise and use Boolean properties reasonably to optimize web page performance and user experience.

HTML code can be cleaner with online validators, integrated tools and automated processes. 1) Use W3CMarkupValidationService to verify HTML code online. 2) Install and configure HTMLHint extension in VisualStudioCode for real-time verification. 3) Use HTMLTidy to automatically verify and clean HTML files in the construction process.

HTML, CSS and JavaScript are the core technologies for building modern web pages: 1. HTML defines the web page structure, 2. CSS is responsible for the appearance of the web page, 3. JavaScript provides web page dynamics and interactivity, and they work together to create a website with a good user experience.

The function of HTML is to define the structure and content of a web page, and its purpose is to provide a standardized way to display information. 1) HTML organizes various parts of the web page through tags and attributes, such as titles and paragraphs. 2) It supports the separation of content and performance and improves maintenance efficiency. 3) HTML is extensible, allowing custom tags to enhance SEO.

The future trends of HTML are semantics and web components, the future trends of CSS are CSS-in-JS and CSSHoudini, and the future trends of JavaScript are WebAssembly and Serverless. 1. HTML semantics improve accessibility and SEO effects, and Web components improve development efficiency, but attention should be paid to browser compatibility. 2. CSS-in-JS enhances style management flexibility but may increase file size. CSSHoudini allows direct operation of CSS rendering. 3.WebAssembly optimizes browser application performance but has a steep learning curve, and Serverless simplifies development but requires optimization of cold start problems.

The roles of HTML, CSS and JavaScript in web development are: 1. HTML defines the web page structure, 2. CSS controls the web page style, and 3. JavaScript adds dynamic behavior. Together, they build the framework, aesthetics and interactivity of modern websites.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

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

Hot Article

Hot Tools

Atom editor mac version download
The most popular open source editor

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

Dreamweaver Mac version
Visual web development tools

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

WebStorm Mac version
Useful JavaScript development tools
