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

The Demo is shown in the video tutorial given below.

Video Tutorial

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