Horizontal Line Examples

Charles Jul 17, 2026

Horizontal lines, a staple in web design, serve to separate content, add visual hierarchy, and direct the reader's attention. They come in various forms, each with its unique use case. Here, we explore different horizontal line examples, their applications, and how to implement them.

an overhead view of a red car parked on the side of a yellow and black striped road
an overhead view of a red car parked on the side of a yellow and black striped road

In this article, we'll delve into various types of horizontal lines, from simple to elaborate, using both CSS and HTML techniques. Let's get started!

a man is standing on the steps in front of a building with an orange roof
a man is standing on the steps in front of a building with an orange roof

Basic Horizontal Lines

At its core, a horizontal line is simply a real or implied line across the page. The simplest way to create one in HTML is by using the   entity with &aronbia; or ¦ to display a long or short line respectively. However, this method is limited in styling options.

Types Of Lines
Types Of Lines

To create more styled lines, we'll use CSS, which offers more control over appearance and behavior.

Solid Horizonatal Lines

the sun is setting over the ocean with surfers in the water
the sun is setting over the ocean with surfers in the water

A basic solid line can be created using CSS's border utility. You can set the height and width of the line, and choose from various border styles like solid, dashed, or double.

Here's an example of a solid line:
<div style="border:1px solid #000;height:2px;width:100%"></div>

Dashed Horizontal Lines

Horizontal e vertical
Horizontal e vertical

To create a dashed line, use the border-style property and set it to dashed. You can also control the gap between dashes with the border-spacing property.

Example:
<div style="border-top:5px dashed #000"></div>

Creative Horizontal Line Techniques

The Importance of Lines in Photography – An Overview with Superb Examples
The Importance of Lines in Photography – An Overview with Superb Examples

Beyond basic lines, we can create more creative separators using CSS. Exploring these options can add uniqueness to your design.

Let's look at two creative techniques: using pseudo-elements and employing gradients.

Rule of thirds
Rule of thirds
a person riding a bike across a cross walk
a person riding a bike across a cross walk
y9 composition
y9 composition
Beginner Photography: How to Take Pictures Like a Pro | ComposeClick
Beginner Photography: How to Take Pictures Like a Pro | ComposeClick
Horizontal Lines as a Compositional Tool in Photography | Iceland Photo Tours
Horizontal Lines as a Compositional Tool in Photography | Iceland Photo Tours
many birds are sitting on power lines against the blue sky with clouds in the background
many birds are sitting on power lines against the blue sky with clouds in the background
Diagonal
Diagonal
a wooden dock that is next to the water at sunset or dawn with no people on it
a wooden dock that is next to the water at sunset or dawn with no people on it

Pseudo-Element Lines

CSS pseudo-elements, like ::before and ::after, allow for additional content without marking it up in the HTML. We can use these to create unique line designs.

Example:
<p style="position:relative;padding-top:20px"><span style="position:absolute;left:0;top:0;width:100%;height:3px;background:#000"></span>Lorem ipsum...</p>

Gradient Lines

CSS gradients offer a way to create colorful, dynamic lines. You can use linear gradients to create single or overlapping lines of varying colors.

Example:
<div style="background:linear-gradient(to right, #ff0000, #00ff00, #0000ff);height:5px;overflow:hidden"></div>

Responsive Horizontal Lines

As-web design becomes increasingly mobile-first, it's crucial that horizontal lines behave well on different screen sizes. We can use CSS media queries to make our lines responsive.

Here's a responsive dashed line that switches to a solid line on smaller screens:
<div style="border-top:5px dashed #000"></div>
@media only screen and (max-width:600px){ div{border-top:5px solid #000;} }</style>

In conclusion, horizontal lines are versatile tools in web design, serving both functional and decorative purposes. Whether you're creating simple separators or more elaborate designs, understanding the techniques explored here will help you create engaging and functional user experiences. Now, go explore, experiment, and bring your unique vision to life!