How does the HTML table label content be centered? Introduction to the use of the Align property of a table

Source: Internet
Author: User
This article focuses on the central use of the table label for HTML tables, as well as how the Align property is used in table labels to help align the table alignment and the text in the table. Now let's take a look at this article.

First, let's look at the use of the table table's contents centered:

Let's first introduce a property, which is the Align property.

The Align property specifies how the table is aligned relative to the surrounding elements.

Usually, the wrapping occurs before and after the HTML table. The effect of other HTML elements around the table can be implemented by using the Align property.

In HTML4.01, the Align property of the BODY element is deprecated, and the align attribute of the BODY element is not supported in the Xhtml1.0strict DTD.

Please use CSS instead.

CSS Syntax:

<table style= "Float:right" >

The syntax for centering the Align property in the table table:

<table align= "center" >

Here are some common property values for the Align property:

Let's look at an example:

<table border= "1" align= "center" >  <tr>    <th>Month</th>    <th>savings</ th>  </tr>  <tr>    <td>January</td>    <td align= "center" >$100</td >  </tr>  <tr>    <td>February</td>    <td>$80</td>  </ Tr></table>

It is obvious in this code that I set the center alignment in the Table tab, which means that the table has been centered in the Web page, followed by the Align attribute in the TD tag, and the text in it is aligned, so the final display of the fresh fruit

, in the middle of the page is displayed, the middle of the TD tag I used the Align attribute to center, so the middle of the text is displayed in the middle of the civilian.

Let's move the text to the right to see:

<table border= "1" align= "center" >  <tr>    <th>Month</th>    <th>savings</ th>  </tr>  <tr>    <td>January</td>    <td align= "center" >200</td >  </tr>  <tr>    <td>February</td>    <td align= "right" >180</td >  </tr></table>

Now the following one TD changed to the right, to see the effect:

, the back of the 180 really to the right, this is the center of the HTML table tag usage, is also the use of the Align property in table. This is the end of this article, there are questions can be in the bottom of the message.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.