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

How InnoDB implements serialization isolation level

Serialization implementation InnoDB implements se...

HTML code to add icons to transparent input box

I was recently writing a lawyer recommendation we...

Solution to IDEA not being able to connect to MySQL port number occupation

I can log in to MYSQL normally under the command ...

What is jQuery used for? jQuery is actually a js framework

Introduction to jQuery The jQuery library can be ...

Solution to the blank page after vue.js packaged project

I believe that many partners who have just come i...

MySQL multi-instance installation boot auto-start service configuration process

1.MySQL multiple instances MySQL multi-instance m...

Detailed explanation of the group by statement in MySQL database group query

1: Statement order of grouping function 1 SELECT ...

html page!--[if IE]...![endif]--Detailed introduction to usage

Copy code The code is as follows: <!--[if IE]&...

JavaScript imitates Jingdong magnifying glass effect

This article shares the specific code for JavaScr...

Several ways to easily traverse object properties in JS

Table of contents 1. Self-enumerable properties 2...

Tutorial on deploying jdk and tomcat on centos7 without interface

1. Install xshell6 2. Create a server connection ...

Solution to Vue data assignment problem

Let me summarize a problem that I have encountere...