To draw a vertical line in HTML, you can use the hr (horizontal rule) tag. The hr tag is used to create a horizontal line, but by setting its width to 1 pixel and its height to the desired length, it can be used to create a vertical line. Here’s an example:

<hr style="border: 0; height: 100px; width: 1px; background-color: black;" />

This will create a vertical line that is 100 pixels high and 1 pixel wide, with a black background color. The border: 0 property is used to remove the default border that the hr tag has.

Alternatively, you can also use CSS to style the vertical line by defining a class for it and use it in your HTML:

<hr class="vertical-line"/>
.vertical-line {
    border: 0;
    height: 100px;
    width: 1px;
    background-color: black;
}

You can also use a div element with a ‘border-left’ and set the width to 0 and the height to the desired length and use it in your HTML:

<div class="vertical-line"></div>
.vertical-line {
    border-left: 2px solid black;
    width: 0;
    height: 100px;
}

This will create a vertical line that is 100 pixels high and 2 pixels wide, with a black color.

You can adjust the width, height, and color of the line to suit your needs.

Also Read:

Categorized in: