How To Change Color and Size of Hr Tag Using CSS

In this tutorial we will see How To Change Color and Size of Hr Tag Using CSS. CSS border-top property is used for this which will change the color and size of Hr tag.

HTML Code

Simple HTML Code is given below, In this code we have Hr Element inside the main body of html document.

The Hr element has no closing tag.

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>How To Change Color and Size of Hr Tag Using CSS</title>
</head>
<body>
<hr>
</body>
</html>

CSS border-top Property

CSS border-top Property is a shorthand property which is used to set the border properties for the top border of the HTML Element.

Three types of border properties are set normally using the border-top and other border shorthand properties. These three properties include width, style and color.

Properties must be in following order.

  1. Width (2px)
  2. Style (Solid)
  3. Color (Black)

CSS border-top Property is supported by all major browsers.

CSS Code

CSS code is given below, in this code we have just used border top property to set the size and color of the Hr Tag.

hr {
border-top: 10px solid red;    
}

More cool examples to design the Hr tag are given below.

Dashed Hr Tag

In this example we have used dashed style border property to make a dashed hr tag.

hr {
border-top: 10px dashed red;    
}

Dotted Hr Tag

In this example we have used dotted style border property to make a dotted hr tag. The size is set to 10px.

hr {
border-top: 10px dotted red;    
}

Rounded Hr Tag

In this example we have used border-radius property to make a rounded hr tag. The radius is set to 10px.

hr {
border-top: 10px solid red;
border-radius: 10px;
}

Demo

Video Tutorial

Watch video tutorial on How To Change Color and Size of Hr Tag Using CSS.

Neumorphic Search Bar Design with HTML and CSS Simple Login Form with Placeholder Animation Pure CSS Button with Folded Corner Background Color Change Slider with HTML CSS and JavaScript 404 Page Not Found Template Design with HTML and CSS Movies Blog Card Design with HTML and CSS Simple CSS Border Animation with before and after Selector Custom Social Select Dropdown Menu with CSS and JavaScript Facebook Offline and Online Notification with CSS and JS New Year 2022 Text Animation with CSS and JS Change Placeholder Color using CSS Custom Select Tag DropDown with CSS and JavaScript Profile Card With Hover Effect using HTML and CSS Simple Price Range Slider With HTML CSS and JavaScript Circle With Two Colors using CSS Card With Ribbon using HTML and CSS Simple Loading Screen using HTML and CSS Disable Textarea Resizable Property using CSS Button like Links using CSS Simple Dropdown Menu Using HTML and CSS Background Color Transition using CSS Highlight Required Input Fields using CSS Disable HTML Link using CSS Difference Between Descendant Selector and Child Selector How To Change Color and Size of Hr Tag Using CSS How To Center Align HTML Table Convert Checkbox To Toggle Button Using CSS Drawing Stars using HTML and CSS Button Bounce Effect using CSS Image as Text Background using CSS background-clip Property Vertically Rotate HTML Element using CSS Vertical Align Middle using CSS Text Over Image Hover Effect - Css Hover Simple CSS Button Hover Effect using Before Selector