Skip to content

Instantly share code, notes, and snippets.

@zgordon
Created April 6, 2011 03:41
Show Gist options
  • Save zgordon/905095 to your computer and use it in GitHub Desktop.
Save zgordon/905095 to your computer and use it in GitHub Desktop.
place a > before or after list items in your breadcrumbs
nav.breadcrumbs ul li::before {
content: ">";
margin-right: 10px;
}
/* Remove the > from before the first breadcrumb */
nav.breadcrumbs ul li:first-child::before {
content: "";
margin-left: 0;
}
@zgordon
Copy link
Author

zgordon commented Apr 6, 2011

This automatically creates something like the following:
Home > About > Team > Zac Gordon

@futuraprime
Copy link

Oh, I see what you're doing. Is there a reason you're not using:

nav.breadcrumbs ul li:first-child:before

?

@zgordon
Copy link
Author

zgordon commented Apr 6, 2011

That does make more sense, and I updated to reflect the more straight forward syntax.

Originally I was doing nth-child(0) cause I thought it was zero indexed, but turns out (1) gives you the first element. Or :first-child as it is now :)

@blg002
Copy link

blg002 commented Apr 7, 2011

I personally list to put the generated content on the anchor element to increase my hit area a bit. I also like to use ::after so I don't have to reset the generated content (assuming you can set up the last breadcrumb, indicating the current page, to not be a link) e.g.

#breadcrumbs a::after { content:'\2002\003e'; }

ISO codes

@zgordon
Copy link
Author

zgordon commented May 14, 2011

Ooh, like that Brad

@flaichi
Copy link

flaichi commented Oct 3, 2022

Hello

there is another way you can use one CSS declaration:

nav.breadcrumbs li+li:before {
content: ">";
margin-right: 10px;
}

regards

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment