Home Web Front-end H5 Tutorial Introduction to the style of html5 table tag (attached is an example of html5 table css centering)

Introduction to the style of html5 table tag (attached is an example of html5 table css centering)

Aug 21, 2018 pm 02:19 PM
html5 table

HTML table tag style introduction (attached is an example of html5 table css centering). This article mainly tells you the definition of html5 table tag and the introduction of various styles.

HTML 5

tag definition and usage:

tag can define a table. Inside the
tag, you can place table titles, table rows, table columns, table cells, and other tables.

html Standard attributes of table tags:

class, contenteditable, contextmenu, dir, draggable, id, irrelevant,

lang, ref, registrationmark , tabindex, template, title

html table style example introduction:

<table border="1">
    <tr>
            <td width="95" align="right" valign="top" nowrap="nowrap"><strong>处理意见:</strong></td>    
            <td id="fnote"  width="300px" colspan="8"> </td>                     
    </tr>
    <tr>
            <td><a href="#" onclick="showad()">审批记录</a></td>
    </tr>                
</table>
Copy after login

width: the width of the column

align: the horizontal arrangement of cell content :right left center

valign: vertical arrangement of cell content: top bottom middle baseline

colspan: the number of columns that the cell can span

rowspan: the number of columns that the cell can span Number of rows

rowspan=3 tr

nowrap: Specifies whether the content in the cell should be folded


table Unique style attributes:

1. Border merge

Attribute: border-collapse

Value:

1. separate

Default value, separate border mode

2.collapse

Border merge mode

2.Border margin

1. Function

Set the distance between adjacent cell borders (similar to cellspacing)

2. Attribute

border-spacing

Value:

1. Take 1 value

means the horizontal and vertical spacing are equal

2. Take 2 values ​​

The horizontal spacing represented by one value

The vertical spacing represented by the second value

Separate the two values ​​with a space

3. Requirements

border-collapse must be separate

Must be valid in separate border mode

3. Title position

Function: Change the title position from the default position to below the table

Attribute: caption-side

Value:

1. top

Default

2. Bottom

The title is under the table

Use div to center the table in css:

I saw that using display: table-cell can render a div into a cell, and the content in the table td is all centered. Then I thought of a div containing a div, and the div inside is vertically centered. I guess it can be done. Use:

Set the outer div to display:table-cell, then the inner div will be automatically centered vertically.

After testing, I found that the inner div is not centered, then use vertical-align to center it. Because:

Only if one element belongs to inline or inline-block (table-cell can also be understood as inline-block level) level, the vertical-align attribute on it will work.

For example, pictures, buttons, single check boxes, single-line/multi-line text boxes and other HTML controls. Only these elements will have an effect on the vertical-align attribute by default.

Now you can use vertical-align:middle in table-cell to center the content vertically. What if I want to achieve horizontal centering? text-algin: center, suitable for inline elements, then I just need to set the div inside to line-block

Code verification:

<style>
        .table {
            display: table-cell;
            vertical-align: middle;
            text-align: center;
        }
        .like {
            display: inline-block;
            width:100px;
            height:50px;
            border:2px solid black;
        }
    </style>
<div class="table" style="width:300px;height: 300px;background-color: #13c4a5">
    <div class="like">
    </div>
</div>
Copy after login

[Related recommendations]

html What does the strong tag mean? Introduction to the specific usage of the strong tag in html

html5 How to use the audio tag? HTML5 automatic playback implementation code example

The above is the detailed content of Introduction to the style of html5 table tag (attached is an example of html5 table css centering). For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
1 months ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Table Border in HTML Table Border in HTML Sep 04, 2024 pm 04:49 PM

Guide to Table Border in HTML. Here we discuss multiple ways for defining table-border with examples of the Table Border in HTML.

HTML margin-left HTML margin-left Sep 04, 2024 pm 04:48 PM

Guide to HTML margin-left. Here we discuss a brief overview on HTML margin-left and its Examples along with its Code Implementation.

Nested Table in HTML Nested Table in HTML Sep 04, 2024 pm 04:49 PM

This is a guide to Nested Table in HTML. Here we discuss how to create a table within the table along with the respective examples.

HTML Table Layout HTML Table Layout Sep 04, 2024 pm 04:54 PM

Guide to HTML Table Layout. Here we discuss the Values of HTML Table Layout along with the examples and outputs n detail.

HTML Input Placeholder HTML Input Placeholder Sep 04, 2024 pm 04:54 PM

Guide to HTML Input Placeholder. Here we discuss the Examples of HTML Input Placeholder along with the codes and outputs.

HTML Ordered List HTML Ordered List Sep 04, 2024 pm 04:43 PM

Guide to the HTML Ordered List. Here we also discuss introduction of HTML Ordered list and types along with their example respectively

Moving Text in HTML Moving Text in HTML Sep 04, 2024 pm 04:45 PM

Guide to Moving Text in HTML. Here we discuss an introduction, how marquee tag work with syntax and examples to implement.

HTML onclick Button HTML onclick Button Sep 04, 2024 pm 04:49 PM

Guide to HTML onclick Button. Here we discuss their introduction, working, examples and onclick Event in various events respectively.

See all articles