Cover Image for How to add a Vertical Line in Html
94 views

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:

  1. 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:
HTML
<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.

  1. 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:
HTML
<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.

YOU MAY ALSO LIKE...

The Tech Thunder

The Tech Thunder

The Tech Thunder


COMMENTS