Home > Web Front-end > Front-end Q&A > How to make div appear centered without writing css

How to make div appear centered without writing css

藏色散人
Release: 2023-02-02 09:16:23
Original
2037 people have browsed it

How to center the div without writing css: 1. Create an HTML sample file; 2. Define some p tag content; 3. Use the "

" tag to achieve without writing CSS can also center the div.

How to make div appear centered without writing css

The operating environment of this tutorial: Windows 10 system, CSS3 version, DELL G3 computer

How to achieve centered display of divs without writing css ?

You can use the

tag.

Centers the text it contains horizontally.

Example

Horizontally center the text in the HTML web page:

<!DOCTYPE html>
<html>
<head> 
<meta charset="utf-8"> 
<title></title> 
</head>
<body>

<p>这是一些文本。</p>
<center>这个文本居中对齐。</center>
<p>这是一些文本。</p>

</body>
</html>
Copy after login

The effect is as follows:

How to make div appear centered without writing css

Note: HTML5 does not support the

tag. Please use CSS instead.

In HTML 4.01, the

element is deprecated.

Recommended learning: "css video tutorial"

The above is the detailed content of How to make div appear centered without writing css. 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