Skip to content

[css-pseudo] generated content between elements #4709

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
tylersticka opened this issue Jan 28, 2020 · 1 comment
Closed

[css-pseudo] generated content between elements #4709

tylersticka opened this issue Jan 28, 2020 · 1 comment

Comments

@tylersticka
Copy link

We currently have and enjoy ::before and ::after tree-abiding generated content pseudo elements.

One use for these is to generate content between elements. For example, you could insert separators between a list of breadcrumb navigation segments:

.breadcrumbs > * + *::before {
  content: "▸";
  margin: 0 2ch;
}

Despite this, I still see hard-coded separators in HTML (vertical bars, bullet or dot characters, etc.) for these sorts of patterns quite often. I have a few thoughts about why this might be:

  • Simple lack of familiarity with or access to a project's CSS.
  • Adjacent element selectors (or other techniques like :not(:first-child)) can be intimidating to some developers.
  • There can sometimes be complexity involved in styling a child pseudo element to appear visually as if it's between its parent and adjacent aunt or uncle.

This made me wonder if there'd be value in a pseudo element that injects content between adjacent matching elements?

.breadcrumbs > *::between {
  content: "▸";
  margin: 0 2ch;
}

Illustration of a breadcrumb navigation pattern with symbols inserted between adjacent elements

(I was encouraged to submit this issue after writing about the idea.)

@Loirooriol
Copy link
Contributor

Closing as dupe of #2960

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

No branches or pull requests

2 participants