Example of how to change the line spacing of HTML table

Example of how to change the line spacing of HTML table

When using HTML tables, we sometimes need to change the line spacing, but changing margin, padding, collapse and other methods are not very effective. Here I found a useful little trick. Use the display attribute + margin to achieve this.
example:

tr{margin-top:0px;padding:0px;display:block;}

Let's take a look at the comparison


tr{margin-top:-10px;padding:0px;display:block;}


It can be clearly seen that the line spacing has been shortened a lot.

Other solutions

Question:

The default display of tr in table is display:table-row. Although it can be changed to display:block, it will lose the unique display effects of tr, such as (automatic alignment of td);

And it is useful to set padding in tr, which can increase the inner margin, but it is useless to set margin, the outer spacing of tr is still 0;

Solution:

Two CSS properties: border-collapse:collapse / separate & border-spacing:10px 10px;

Need to use border-collapse & border-spacing to control the spacing of tr;

like:

<table style="border-collapse:separate; border-spacing:10px;">
    <tr></tr>
</table>

This is the end of this article about examples of how to change the line spacing of HTML tables. For more relevant content about HTML table line spacing, please search 123WORDPRESS.COM’s previous articles or continue to browse the following related articles. I hope that everyone will support 123WORDPRESS.COM in the future!

<<:  Sharing the structure and expression principles of simple web page layout

>>:  CSS3 uses transform-origin to achieve dot distribution on a large circle and rotation effects

Recommend

Three methods of inheritance in JavaScript

inherit 1. What is inheritance Inheritance: First...

Docker container monitoring and log management implementation process analysis

When the scale of Docker deployment becomes large...

How to implement scheduled backup of CentOS MySQL database

The following script is used for scheduled backup...

Element avatar upload practice

This article uses the element official website an...

Who is a User Experience Designer?

Scary, isn't it! Translation in the picture: ...

How to migrate mysql storage location to a new disk

1. Prepare a new disk and format it with the same...

TABLE tags (TAGS) detailed introduction

Basic syntax of the table <table>...</tab...

How to use the Marquee tag in XHTML code

In the forum, I saw netizen jeanjean20 mentioned h...

Why do code standards require SQL statements not to have too many joins?

Free points Interviewer : Have you ever used Linu...

How to install Oracle_11g using Docker

Install Oracle_11g with Docker 1. Pull the oracle...

BUG of odd width and height in IE6

As shown in the figure: But when viewed under IE6...

How to purchase and install Alibaba Cloud servers

1. Purchase a server In the example, the server p...

MySQL 5.7.18 MSI Installation Graphics Tutorial

This article shares the MySQL 5.7.18 MSI installa...