Skip to content
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

[css-inline-3] text-box accumulation unexpected behavior #11472

Open
bakura10 opened this issue Jan 10, 2025 · 0 comments
Open

[css-inline-3] text-box accumulation unexpected behavior #11472

bakura10 opened this issue Jan 10, 2025 · 0 comments

Comments

@bakura10
Copy link

Hello,

I've been playing with text-trim and found a rather unexpected behavior when applying text-trim on a parent, which applies what is apparently called "text-box-trim accumulation" (#5426).

You can reproduce the issue here: https://codepen.io/bakura10/pen/GgKMvqR

image

Ideally, this is the end result I would like:

image

This is apparently the expected result but I find it rather surprising and I'm sure other developers will find it surprising.

What we want in most cases is trimming of the first and last elements on content where I don't control the exact order of elements or which elements are being added (think of RTE or builder), independently of what they are (basically, I expected it to work a bit like margin-trim).

I am currently emulating what I want using this:

.prose > :first-child:not(.button) {
  text-trim: trim-start cap alphabetic;
}

.prose > :last-child:not(.button) {
  text-trim: trim-end cap alphabetic;
}

This however won't work if the DOM ended up being nested:

<div class="prose">
  <p>I'm trimed start</p>

  <div clas="max-w-sm">
    <p>I won't be trim end<p>
  </div>
</div>

Thanks.

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

No branches or pull requests

1 participant