ScanSkill
CSS Examples

How to Create a Vertical Line using CSS

In this example, we will learn how to create a vertical line using CSS. We will be using the height and border-right property.

Prerequisites

Example

HTML

<div class="line"></div>

CSS

.line {
            border-right: 5px solid black;
            height: 50px;
        }

Output

How to Create a Vertical Line using CSS

Here, we used height: 50px to specify the height of the line to 50px then defined border-right: 5px solid black to set the thickness of the line to 5px and the color black .We can use any of the border-right or border-left property as both will set the vertical line.

Conclusion

In this example, we learned how to create a vertical line using CSS. We used the height property to set the height of the line and border-right property to set the thickness and color of the line.