
How to add a Vertical Line in Html
To add a vertical line in HTML, you can use CSS border properties or HTML <hr>
element with appropriate styling. Here are two common approaches:
- Using CSS border properties:
You can create a vertical line by applying a border to an HTML element and adjusting its width, height, and color. Here’s an example:
<div style="border-left: 1px solid black; height: 200px;"></div>
In this example, a <div>
element is used, and the border-left
property creates a vertical line on the left side of the element with a solid black color. Adjust the height
property as needed to control the length of the line.
- Using
<hr>
element with styling:
The<hr>
element is typically used to create horizontal lines, but with appropriate styling, it can be used to create vertical lines as well. Here’s an example:
<hr style="border: none; border-left: 1px solid black; height: 200px;">
In this example, the <hr>
element is styled by setting the border
property to none to remove the default horizontal line, and then the border-left
property creates a vertical line on the left side of the element with a solid black color. Adjust the height
property as needed.
These are two simple ways to add a vertical line in HTML. You can choose the method that best fits your requirements and styling preferences.