The contents of the table in HTML are displayed horizontally and vertically in the center

The contents of the table in HTML are displayed horizontally and vertically in the center

Specify in CSS style file

#class td /*Set the table text to be aligned left and right and top and bottom*/ 
{  
    vertical-align: middle;
    text-align: center;  
}
/*class is the class it belongs to*/
<div id="class" align="center" style="margin: 0cm 0cm 0pt; text-align: left">                                                                      
<table class="table table-bordered" border="1" width="100%" style="font-size: 14pt; color: #000000; font-family: 楷体;mso-ascii-font-family: 'times new roman'; mso-hansi-font-family: 'times new roman'">                                                             
<caption><h2 style="text-align: left;font-size: 16pt;font-family: 宋体;color: red;">title</h2><
/caption>                                                              
<tbody>                                                                 
<tr style="font-weight: bold;mso-bidi-font-size: 12.0pt;font-family: 宋体;" >                                                                      
<td>Serial number</td>                                                                      
<td>Applicable situations</td>                                                                      
 <td>Details</td>                                                                       
<td>Remarks</td>                                                                   
 </tr>                                                                                                                                       
<tr>                                                                    
<td>1</td>                                                                     
<td>xxxxx</td>                                                                      
<td style="text-align: left;"> <!--Specify left alignment-->                                                                     
 <span>                                                                             
xxxxxx<br>                                                                                                                                                        
</span>                                                                      
</td>                                                                       
<td><a href="#">View details</a>
</td>                                                              
</tr>                                                
</tbody>                                                          
</table> 
</div>

The above specifies id as class in div, then the attribute td of table uses the style specified in css, as shown in the figure

這里寫圖片描述

The above is what I introduced to you about the horizontal and vertical centering of the table content in HTML. I hope it will be helpful to you. If you have any questions, please leave me a message and I will reply to you in time. I would also like to thank everyone for their support of the 123WORDPRESS.COM website!

<<:  How to encapsulate axios in Vue

>>:  Detailed explanation of the use of MySQL concatenation function CONCAT

Recommend

Steps to set up Windows Server 2016 AD server (picture and text)

Introduction: AD is the abbreviation of Active Di...

HTML multimedia application: inserting flash animation and music into web pages

1. Application of multimedia in HTML_falsh animat...

Share 13 excellent web wireframe design and production tools

When you start working on a project, it’s importa...

Mysql master/slave database synchronization configuration and common errors

As the number of visits increases, for some time-...

Introduction to JavaScript conditional access attributes and arrow functions

Table of contents 1. Conditional access attribute...

How to quickly clean up billions of data in MySQL database

Today I received a disk alarm exception. The 50G ...

Example of how to exit the loop in Array.forEach in js

Table of contents forEach() Method How to jump ou...

Analysis of parameter transfer process of driver module in Linux

Declare the parameter name, type and permission y...

Each time Docker starts a container, the IP and hosts specified operations

Preface Every time you use Docker to start a Hado...

Understanding of CSS selector weight (personal test)

Copy code The code is as follows: <style type=...

How to solve the problem of clicking tomcat9.exe crashing

A reader contacted me and asked why there were pr...

Detailed explanation of JavaScript object conversion to primitive value

Table of contents Object.prototype.valueOf() Obje...

Detailed tutorial on configuring nginx for https encrypted access

environment: 1 CentOS Linux release 7.5.1804 (Cor...