Home > Web Front-end > Front-end Q&A > Can css be used for the hr tag in html5?

Can css be used for the hr tag in html5?

WBOY
Release: 2022-01-23 15:34:58
Original
2854 people have browsed it

In HTML5, the hr tag can be styled with css. The css style can define how to display HTML elements. You only need to use the style attribute to set the hr element with css style. The syntax is "


" or "hr{css style code;}".

Can css be used for the hr tag in html5?

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

Can I use css for the hr tag in html5?

Simply put, hr is a horizontal dividing line (horizontal rule) on the html page, which can visually separate the document into various parts. . Needs to be created in the HTML page via the


tag.

Then let’s take a look at the default hr tag style:

Can css be used for the hr tag in html5?

is just a black line, which is not beautiful at all, let alone using


Now that the page is beautiful, you need to use css to set the style of hr.

css to set hr style

How do we use css to set hr style? In fact, it is very simple. You can set the style of hr through the css border attribute and css background-image attribute:

1.css sets the thickness (bold) and color of hr

<hr style="border: 5px solid red;"/><!--修改的样式-->
<br />
<hr /><!--默认的样式-->
Copy after login

Can css be used for the hr tag in html5?

2.css sets the dashed line style of hr (color is blue)

<hr   style="max-width:90%"/>
Copy after login

Can css be used for the hr tag in html5?

3.css sets the double line style of hr

<hr   style="max-width:90%"/>
Copy after login

Can css be used for the hr tag in html5?

4. css to set the 3D three-dimensional style of hr

<hr   style="max-width:90%"/>

Copy after login

Can css be used for the hr tag in html5?

5.css to set the gradient style of hr

HTML code:

<hr class="style-one"/>
<br/>
<hr class="style-two"/>
Copy after login

css code:

hr.style-one {/*透明渐变水平线*/
 width:80%;
 margin:0 auto;
 border: 0;
 height: 4px;
 background-image: linear-gradient(to right, rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.75), rgba(0, 0, 0, 0));
}
hr.style-two{/*渐变*/
 width:80%;
 margin:0 auto;
 border: 0;
 height: 4px;
 background: #333;
 background-image: linear-gradient(to right, red, #333, rgb(9, 206, 91));
}
Copy after login

Can css be used for the hr tag in html5?

The above are just a few simple examples. The style of the hr tag can also be realized through CSS. . Everyone can give it a try!

Recommended tutorial: "html video tutorial"

The above is the detailed content of Can css be used for the hr tag 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