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.

Social Media Menu with Popup Tooltip using HTML and CSS Horizontal Navigation Menu with HTML and CSS Responsive Sidebar Menu with CSS and JavaScript Cool CSS Button with Hover Animation Pure CSS Custom Radio Buttons Custom Emoji Radio Buttons with CSS Color Picker Design with HTML CSS and JavaScript Custom Radio Buttons with CSS Engraved HTML Buttons With CSS Neumorphic Buttons Design with CSS Cool Profile Card Design with HTML 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 Simple Price Range Slider With HTML CSS and JavaScript Profile Card With Hover Effect using HTML and CSS Circle With Two Colors using CSS Simple FAQ Accordion With HTML CSS and JavaScript