” or “hr{css style code;}”."/> ” or “hr{css style code;}”.">

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

Can css be used for the hr tag in html5?

WBOY
WBOYOriginal
2022-01-23 15:34:582806browse

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 /><!--默认的样式-->

Can css be used for the hr tag in html5?

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

<hr style="height:1px;border:none;border-top:1px dashed #0066CC;"/>

Can css be used for the hr tag in html5?

3.css sets the double line style of hr

<hr style="height:3px;border:none;border-top:3px double red;"/>

Can css be used for the hr tag in html5?

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

<hr style=" height:5px;border:none;border-top:5px ridge green;"/><!--3D 垄状-->
<hr style=" height:10px;border:none;border-top:10px groove skyblue;"/><!--3D 凹槽-->

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"/>

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));
}

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!

Statement:
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