Simple Breadcrumb Menu With Pure HTML CSS (Free Download)

Welcome to a quick tutorial on how to create a simple breadcrumb menu with pure HTML and CSS. If you are looking to add a breadcrumb menu to your website, there’s really no need to use a “third-party plugin”. We can create a simple one using just pure HTML and CSS – Read on!

ⓘ I have included a zip file with all the source code at the start of this tutorial, so you don’t have to copy-paste everything… Or if you just want to dive straight in.

 

 

QUICK SLIDES

 

TABLE OF CONTENTS

Download & Notes Breadcrumb Useful Bits & Links
The End

 

DOWNLOAD & NOTES

Firstly, here is the download link to the example code as promised.

 

QUICK NOTES

If you spot a bug, feel free to comment below. I try to answer short questions too, but it is one person versus the entire world… If you need answers urgently, please check out my list of websites to get help with programming.

 

EXAMPLE CODE DOWNLOAD

Click here to download all the example source code, I have released it under the MIT license, so feel free to build on top of it or use it in your own project.

 

 

PURE HTML CSS BREADCRUMBS

All right, let us now get into the steps of creating a breadcrumb menu with HTML and CSS.

 

BREADCRUMB MENU DEMO

 

PART 1) THE HTML

1-breadcrumb.html
<ul class="breadcrumb">
  <li><a href="http://site.com">
    Home
  </a></li>
  <li><a href="http://site.com/shop">
    Shop
  </a></li>
  <li><a href="http://site.com/shop/toys">
    Toys
  </a></li>
</ul>

Look no further, this is just your “regular HTML list”.

  • Does not matter if it is <ul> or <ol>. Just add class="breadcrumb" to it, we will turn this into a breadcrumb menu using CSS.
  • Then, append your <a> links inside the list items.

 

 

PART 2) THE CSS

2-breadcrumb.css
/* (A) SIZING & FONT */
.breadcrumb, .breadcrumb * {
  font-family: arial, sans-serif;
  box-sizing: border-box;
}
 
/* (B) LIST TO HORIZONTAL MENU */
.breadcrumb {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
}
.breadcrumb li { padding: 10px; }
 
/* (C) MENU ITEMS */
.breadcrumb a {
  text-decoration: none;
  color: #288be1;
  font-weight: 700;
}
 
/* (D) ARROW TRAIL */
.breadcrumb li::after {
  content: ">";
  margin-left: 10px;
  color: #59caff;
}
.breadcrumb li:last-child::after { content: none; }
  1. The font of the breadcrumb menu.
  2. Turning the list into a horizontal menu.
    • list-style: none will remove the bullet points.
    • padding: 0 and margin: 0 to remove the original list indentations.
    • display: flex to turn the list into a horizontal layout.
  3. Cosmetics for the <a> links.
  4. In the li::after pseudo-class, we use content: ">" to insert the arrow trails between each breadcrumb item.

 

 

PART 3) BREADCRUMB SEO

Here are 3 possible ways to add structured data, for you guys who want to do SEO for the breadcrumb. This is completely optional though.

 

3A) JSON LD

3a-json-ld.html
<head>
<script type="application/ld+json">
{
  "@context": "https://schema.org",
  "@type": "BreadcrumbList",
  "itemListElement": [{
    "@type": "ListItem",
    "position": 1,
    "name": "Home",
    "item": "http://site.com"
  },{
    "@type": "ListItem",
    "position": 2,
    "name": "Shop",
    "item": "http://site.com/shop"
  },{
    "@type": "ListItem",
    "position": 3,
    "name": "Toys",
    "item": "http://site.com/shop/toys"
  }]
}
</script>
</head>

First, we have JSON-LD (JSON for linking data). Not going into the “boring details”, but just insert a <script type="application/ld+json"> into your <head> section, with all the breadcrumb items.

 

3B) RDFA

3b-rdfa.html
<ul class="breadcrumb vocab="https://schema.org/" typeof="BreadcrumbList"">
  <li property="itemListElement" typeof="ListItem">
    <a href="http://site.com" property="item" typeof="WebPage">
      <span property="name">Home</span>
    </a>
    <meta property="position" content="1">
  </li>
  <li property="itemListElement" typeof="ListItem">
    <a href="http://site.com/shop" property="item" typeof="WebPage">
      <span property="name">Shop</span>
    </a>
    <meta property="position" content="2">
  </li>
  <li property="itemListElement" typeof="ListItem">
    <a href="http://site.com/shop/toys" property="item" typeof="WebPage">
      <span property="name">Toys</span>
      Toys
    </a>
    <meta property="position" content="3">
  </li>
</ul>

Next, we have RDFa (Resource Description Framework in Attributes). Instead of a separate <script type="application/ld+json"> tag, we directly define the data structure in HTML tags.

 

3C) MICRODATA

3c-microdata.html
<ul class="breadcrumb" itemscope itemtype="https://schema.org/BreadcrumbList">
  <li itemprop="itemListElement" itemscope itemtype="https://schema.org/ListItem">
    <a href="http://site.com" itemprop="item">
      <span itemprop="name">Home</span>
    </a>
    <meta itemprop="position" content="1"/>
  </li>
  <li itemprop="itemListElement" itemscope itemtype="https://schema.org/ListItem">
    <a href="http://site.com/shop" itemprop="item">
      <span itemprop="name">Shop</span>
    </a>
    <meta itemprop="position" content="2"/>
  </li>
  <li itemprop="itemListElement" itemscope itemtype="https://schema.org/ListItem">
    <a href="http://site.com/shop/toys" itemprop="item">
      <span itemprop="name">Toys</span>
    </a>
    <meta itemprop="position" content="3"/>
  </li>
</ul>

Finally, one of the most common methods (and my preferred way) – Adding microdata.

 

 

USEFUL BITS & LINKS

That’s all for the tutorial, and here is a small section on some extras and links that may be useful to you.

 

DON’T OVER-OPTIMIZE!

Yes, it is good to add some data structure, that will help search engines to better understand the layout of your website. But don’t overdo it, that is a common mistake called “over-optimization”; Adding a JSON-LD tag and bloating your website full with microdata will not help you to rank first miraculously.

Structured data is not some “secret code to rank first”… So between JSON-LD, RFDa, and microdata – Just use one, or none at all. Search engines are smart enough to figure things out these days anyway.

 

LINKS & REFERENCES

 

INFOGRAPHIC CHEAT SHEET

HTML CSS Breadcrumb Menu (click to enlarge)

 

THE END

Thank you for reading, and we have come to the end. I hope that it has helped you to better understand, and if you want to share anything with this guide, please feel free to comment below. Good luck and happy coding!

Leave a Comment

Your email address will not be published.