Home > Web Front-end > Front-end Q&A > Can't align be used in html5?

Can't align be used in html5?

WBOY
Release: 2022-08-02 16:44:41
Original
4090 people have browsed it

The align attribute cannot be used in html5. This attribute is no longer supported in html5; the align attribute mainly affects the horizontal alignment of the set elements. Setting the align attribute for tables, text, images and other elements has its performance The form is inconsistent, you can use the "text-align" attribute in CSS to replace the align attribute.

Can't align be used in html5?

The operating environment of this tutorial: Windows 10 system, HTML5 version, Dell G3 computer.

align cannot be used in html5

The align attribute is used in HTML tables, text, images and other elements. The align attribute mainly affects the horizontal alignment of the set elements, providing tables, text, and When the align attribute is set on elements such as images, their expressions are inconsistent.

align in html means "alignment", which is an attribute of the html tag. It is used to set the alignment of the content in the element. The syntax is

<element align="值">
Copy after login

The attribute values ​​include left, right, center, etc., you can set the content to be aligned to the left, right or centered.

The

align attribute is no longer supported in HTML5, please use CSS instead.

's align attribute is deprecated in HTML 4.01. in HTML 4.01. The

align attribute specifies the horizontal alignment of content within a

element.

CSS alternative syntax:

<div style="text-align:center">
Copy after login

The example is as follows:

<!DOCTYPE html>
<html>
<body>
<p>This is a paragraph. This text has no alignment specified.</p>
<div style="text-align:center;border:1px solid red">
This is some text in a div element!
</div>
<p>This is a paragraph. This text has no alignment specified.</p>
</body>
</html>
Copy after login

Output result:

Cant align be used in html5?

(Learn Video sharing: css video tutorial, html video tutorial)

The above is the detailed content of Can't align be used in html5?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template