Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3215310
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T15:09:46+00:00 2026-05-17T15:09:46+00:00

I’m currently struggling with the problem of trimming a breadcrumb navigation so it doesn’t

  • 0

I’m currently struggling with the problem of trimming a breadcrumb navigation so it doesn’t destroy my site’s design.

The problem is the following: The breadcrumb navigation has a fixed width (let’s say 900px) – So, if the user navigates to an item whose location results in a breadcrumb that is larger than 900px I’d have to trim it to fit into the design.

So, the part where I’m stuck is this: How can I decide how much to trim and where to trim? I figured out that I could just trim the overflow of text in the middle of the breadcrumb, so it would result in

Some > Navigation > That > … > is > too > long

But how can I decide where to cut? And how will I be able to preserve the anchors of the elements from being trimmed?!

I’m really stuck on this, is there any accepted way to deal with such issues?!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T15:09:46+00:00Added an answer on May 17, 2026 at 3:09 pm

    Keep the root element, remove following elements until the breadcrumb fits. I’d actually recommend you to do this in JavaScript as then you’d have methods to calculate the pixel width of the breadcrumb, whereas in PHP you’d have to use a fixed number of characters as the break point which would always result in different lengths. Using JS would be better anyways for SEO and such, as the links would still be there, only hidden.

    Assuming you have a simple list element as your breadcrumb:

    <ul id="breadcrumb">
        <li><a href="/">Home</a></li>
        <li><a href="/products/">Products</a></li>
        <li><a href="/products/hats/">Hats</a></li>
        <li><a href="/products/hats/large/">Large</a></li>
        <li><a href="/products/hats/large/red/">Red</a></li>
        <li><a href="/products/hats/large/red/round/">Round</a></li>
    </ul>
    

    You can then trim the length like this (using jQuery):

    if($('#breadcrumb').width() > 900) {
        $('#breadcrumb li:first').after('<li>...</li>');
    
        while($('#breadcrumb').width() > 900) {    
            $('#breadcrumb li').eq(2).remove();
        }
    }
    

    A simple example and probably doesn’t work, but should give you some idea.

    BTW, if you want to do the trimming in PHP, you have to do it when the breadcrumb is being formed if you want to keep it simple. If you start trimming afterwards, you’d have to resort to some pretty complex regular expressions or to including some kind of DOM parser in your project to keep the anchor tags intact.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I am currently running into a problem where an element is coming back from
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I want use html5's new tag to play a wav file (currently only supported

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.