Responsive Horizontal Timeline using HTML and CSS

Introduction

Want to show steps or milestones in a visual way? A horizontal timeline is perfect for that! In this article, you’ll learn how to build a beautiful and responsive timeline using just HTML and CSS.

Whether you’re showcasing your personal journey, project milestones, product releases, or a company’s history, timelines are a great visual way to engage users. And the best part? You don’t need JavaScript or any framework for this — pure HTML and CSS gets the job done!

Why Use a Horizontal Timeline?

Horizontal timelines are especially useful when you have events or steps that should be displayed from left to right — like:

  • Showcasing career progression
  • Displaying company growth or milestones
  • Explaining a process or flow in steps
  • Portfolio timelines (projects, launches, versions)

HTML Code

Here’s the basic structure of our timeline with some events:

<div class="timeline-container">
  <div class="timeline">

    <div class="timeline-item">
      <div class="timeline-content">
        <h3>2017</h3>
        <p>Started learning HTML & CSS.</p>
      </div>
    </div>

    <div class="timeline-item">
      <div class="timeline-content">
        <h3>2019</h3>
        <p>Built my first responsive website.</p>
      </div>
    </div>

    <div class="timeline-item">
      <div class="timeline-content">
        <h3>2021</h3>
        <p>Started freelancing and building projects for clients.</p>
      </div>
    </div>

    <div class="timeline-item">
      <div class="timeline-content">
        <h3>2023</h3>
        <p>Joined a tech company as a Front-End Developer.</p>
      </div>
    </div>

  </div>
</div>

CSS Code

This CSS makes your timeline horizontal, scrollable on smaller devices, and beautiful on all screen sizes:

.timeline-container {
  overflow-x: auto;
  padding-bottom: 20px;
}

.timeline {
  display: flex;
  gap: 30px;
  padding: 20px;
  min-width: 700px;
}

.timeline-item {
  background-color: #fff;
  padding: 20px;
  border-radius: 12px;
  border: 2px solid #0ea5e9;
  min-width: 200px;
  position: relative;
  flex-shrink: 0;
  box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.timeline-item::before {
  content: '';
  position: absolute;
  width: 12px;
  height: 12px;
  background: #0ea5e9;
  border-radius: 50%;
  top: -10px;
  left: 50%;
  transform: translateX(-50%);
}

.timeline-content h3 {
  color: #0ea5e9;
  margin-bottom: 10px;
}

.timeline-content p {
  font-size: 0.95rem;
  color: #555;
}

@media (max-width: 600px) {
  .timeline {
    flex-direction: column;
  }

  .timeline-item {
    min-width: 100%;
  }

  .timeline-item::before {
    left: 0;
    top: -10px;
    transform: none;
  }
}

Final Thoughts

This horizontal timeline is just the beginning — you can further enhance it with icons, animations, or even integrate JavaScript for interactivity. You could also make the timeline dynamic by fetching event data from an API or a database.

Hope this helped you understand how to build a clean timeline layout using just HTML and CSS. Try customizing the colors, adding more events, or making it vertical — the possibilities are endless!

Happy Coding! 💻

How to Remove Filter in CSS – With Real Example

More

Share via
Copy link