How to set hr centered in css

WBOY
Release: 2021-11-19 19:22:17
Original
7023 people have browsed it

In CSS, you can use the "text-align" attribute to set the hr center. The function of this attribute is to specify the horizontal alignment of the element. You only need to add the "text-align:center;" style to the hr element. Can.

How to set hr centered in css

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

How to set hr centered in css

In css, you can use the "text-align:center;" attribute to set hr centered,

The text-align attribute specifies the horizontal alignment of text in an element.

This attribute sets the horizontal alignment of text within block-level elements by specifying the point at which the line box is aligned. The value justify is supported by allowing user agents to adjust the spacing between letters and words in line content; different user agents may get different results.

The example is as follows:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
<style type="text/css">
    hr{
        width:50%;
        text-align:center;
    }
    </style>
<h1>HTML</h1>
<p>HTML 是用于描述 web 页面的一种语言。</p>
<hr>
<h1>CSS</h1>
<p>CSS 定义如何显示 HTML 元素。</p>
</body>
</html>
Copy after login

Output result:

How to set hr centered in css

(Learning video sharing: css video tutorial)

The above is the detailed content of How to set hr centered in css. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
css
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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!