Skip to content

[css-pseudo] add "nth-*" pseudo element #745

Closed

Description

@carnoxen

Pseudo class has "nth-*" selectors , but pseudo element don't. How about adding "nth-*" selectors?
Here's what @chriscoyier says: https://css-tricks.com/a-call-for-nth-everything/
At least, I want the pseudo element spec to implement the selectors:

  • ::nth-line() / ::last-line / ::nth-last-line()
  • ::nth-letter() / ::last-letter() / ::nth-last-letter()

Once implemented, it would be powerful to design the thing like code block, poem, etc without code complexity.

Activity

  1. frivoal commented on Nov 22, 2016

    @frivoal
    Collaborator

    This sits at the uncomfortable intersection of useful and freaking hard to implement.

    The existing ::first-line and ::first-letter already cause lots of headaches, and implementers are not looking forward to more of that complexity.

    That said, the kind of things you want to do with ::nth-line might end up being addressable with:

    thing {
      max-lines: 1;
      continue: fragments;
    }
    thing::nth-fragment() {
    }
    

    This is and early / unstable draft, but have a look here for more details:
    https://drafts.csswg.org/css-overflow-4/#fragmentation
    https://drafts.csswg.org/css-overflow-4/#fragment-pseudo-element

    As for ::nth-letter, I am not aware of any substitute, but neither am I aware of strong use cases. If you want this explicitly (instead of just for completeness sake), could you give some examples of where you'd use it and why existing CSS isn't good enough? There's one in the blog you linked to, but do you have more?

  2. fantasai commented on Dec 28, 2018

    @fantasai
    Collaborator

    Closing out per #745 (comment)
    It's possible we might revisit this idea in the far far future, but for now, based on past WG and implementer discussions, I think it's unlikely to happen.

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions