Vertical Line Between Text CSS

Vertical Line Between Text CSS
Code Snippet:Vertical Line With Text In Middle
Author: dhanraj
Published: January 19, 2024
Last Updated: January 22, 2024
Downloads: 5,888
License: MIT
Edit Code online: View on CodePen
Read More

This simple CSS code snippet helps you to add a vertical line between text. It uses CSS before and after pseudo selectors to draw a line to the up and down of the text.  The thickness of the line can be set with width and height property. Similarly, the background property defines the line color.

How to Create Vertical Line Between Text

1. First of all, create a span element and place your text inside it.

<span>
   CodeHim      
</span>

2. Now, style the CSS styles for the span element as follows to draw a vertical line between text. You can also use a class name instead of span, then add class name to your HTML element where you want to display vertical line.

span{
    position: relative;
    height: 150px;
    width: 67px;
    display: block;
    text-align: center;
    padding-top: 100px;
    margin: 10px auto;
}
span:before {
    border-left: 1px solid black;
    content: "";
    display: block;
    height: 65px;
    left: 34px;
    position: absolute;
    top: 30px;
    width: 1px;
    z-index: 0;
}

span:after {
    border-left: 1px solid black;
    content: "";
    display: block;
    height: 67px;
    left: 32px;
    position: absolute;
    top: 123px;
    width: 1px;
    z-index: 0;
}

That’s all! hopefully, you have successfully created a vertical line between text. If you have any questions or suggestions, feel free to comment below.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

About CodeHim

Free Web Design Code & Scripts - CodeHim is one of the BEST developer websites that provide web designers and developers with a simple way to preview and download a variety of free code & scripts. All codes published on CodeHim are open source, distributed under OSD-compliant license which grants all the rights to use, study, change and share the software in modified and unmodified form. Before publishing, we test and review each code snippet to avoid errors, but we cannot warrant the full correctness of all content. All trademarks, trade names, logos, and icons are the property of their respective owners... find out more...

Please Rel0ad/PressF5 this page if you can't click the download/preview link

X