Skip to content

[css-pseudo] Which properties to reset in ::marker #4568

Open

Description

@faceless2

Migrated from #4474

The specification currently states that only the following properties apply to ::marker:

  • all font properties (see [CSS3-FONTS])
  • the white-space property (see [CSS3TEXT])
  • the color property (see [CSS3COLOR])
  • the text-combine-upright, unicode-bidi, and direction properties (see [CSS-WRITING-MODES-3])
  • the content property (see [CSS-LISTS-3])

...and that this list is likely to be revised. But markers don't exist in a vacuum; they're part of the tree, so even properties that don't apply will need to be reset if they're inheritable, to initial or some other sensible value.

As of today the specification has

unicode-bidi: isolate;
font-variant-numeric: tabular-nums;

with white-space to be reset to something closely resembling pre (#4448).

So, starting with inheritable properties in css-text and text-shadow from css-text-decor, and working on the presumption that markers will always be limited to a single line, we have these properties to consider:

propertyapplicability to markers
hanging-punctuationprobably n/a
hyphensn/a
letter-spacing?
line-breakn/a
overflow-wrapn/a
tab-sizetabs in markers?
text-align-*?
text-indent?
text-justifywill depend on text-align
text-transform?
white-spacealready covered
word-breakn/a
word-spacing?
word-wrapn/a
word-wrapn/a
text-shadow?

I'm going to leave tab-size, it's technically applicable but the only place this would ever happen is a WPT test-case. I suppose a decision has to be made, but I doubt it matters what that is.

I think hanging-punctuation doesn't apply - all values other than force-end will apply only if the text wraps, and force-end only applies to the end of the line. As white-space won't collapse in markers, and a space will almost always follow the punctuation I don't think that's the case, but will test for completeness (although as this depends on browser support for both hanging-punctuation and custom markers, it might not be a very useful test).

Test is here: https://output.jsbin.com/rusilefogo

Findings:

propertyFirefoxChromeSafari
letter-spacingNYY
word-spacingNYY
text-indentNNN
text-alignYNN
text-transformNYN
text-shadowNYN
hanging-punctuationN--

Everyone's different, isn't that fun! To start the ball off on the discussion below, I'd suggest:

  • letter-spacing - arguable either way.
  • word-spacing - arguable either way but I lean towards no - as white-space will separate the marker from the content, word-spacing will always be applied and I don't think that's going to be compatible with what users expect.
  • text-indent - surely no. Every browsers says no.
  • text-align - I think this has to be a no, the FireFox results are clearly wrong
  • text-transform - arguable either way; if it wasn't for the kana transformations I would say no, but I'm not sure how applicable they are to markers so can't comment
  • text-shadow - arguable either way but I lean towards yes - I think the result in Chrome is more consistent visually.
  • hanging-punctuation - if it applies at all, resetting to initial seems a good idea and matches current behaviour in Firefox. It's not testable in Chrome or Safari, as we need to remove the trailing space from the marker content, which I can't do without ::marker/content or @counter-style support.

(edit: pinging @MatsPalmgren @dauwhe and @fantasai for input as suggested by @fantasai in the original issue)

Activity

  1. Loirooriol commented on Dec 6, 2019

    @Loirooriol
    Contributor

    There is also #4206 about text-transform.
    Note that not even Chromium legacy and Chromium LayoutNG are interoperable.

    text-indent - surely no. Every browsers says no.

    Actually, Chromium LayoutNG supports it, but you don't see it because of the marker alignment, so you need ::marker { direction: rtl }. And Firefox supports it in content markers but not in legacy markers (nsBulletFrame).

    text-align - I think this has to be a no

    Note Chromium LayoutNG does support it, but maybe not like you expected? If you use content: 'ab\a c' and white-space: pre, with text-align: left the c appears below the a, and with text-align: right it appears below the b.

    In general I would lean towards not resetting properties unless strictly necessary.

  2. faceless2 commented on Dec 6, 2019

    @faceless2
    Author

    Whoops, I should have qualified that I'm testing with the versions I have here, which are the latest public ones available - your view from inside is much more accurate, thank you. I presume you have edit rights, if you want to edit that table to correct it please be my guest.

    I'm making the presumption that markers will not contain newlines. As I said in #4448 I think multi-line markers are a can-of-worms - if they're allowed, the list above will certainly need updating.

  3. fantasai commented on Dec 6, 2019

    @fantasai
    Collaborator

    so even properties that don't apply will need to be reset if they're inheritable

    So... I think this is an argument for clearly defining which properties apply to raw text vs to boxes vs to line boxes or their interaction with text, and clarifying that you can set declarations on ::marker and they will inherit to the text it contains. (Applying a property to a box vs letting it inherit through and affect its contents are slightly different concepts.)

    I have no problem with allowing properties that affect text and not boxes to be applied to ::marker and to inherit through, since that wouldn't change behavior as we further develop a layout model for marker boxes.

    I am concerned about things like text-align and text-indent since they reference the edges of the line box, and therefore their behavior could change as we define the layout model for marker boxes. From my perspective, setting text-align: end !important; text-indent: 0 !important; hanging-punctuation: none !important in the UA style sheet would be appropriate at this point in time (and at the point where layout is clearly defined, we can drop the !important.).

    For the rest, I would let text-shadow inherit from the list item element the same as color. I suspect it's better to block inheritance of text-transform by default via text-transform: none, since casing is often used to distinguish list items. Wrt resetting word-spacing and letter-spacing I'm unsure. We have to remember that this resetting would be applied to inside markers as well as outside ones, and for inside markers in particular might make sense to inherit the paragraph's conventions.

    So I guess my proposal would be:

    • Allow properties that style text directly to ::marker, i.e. add word-spacing, letter-spacing, text-shadow, and maybe text-emphasis (if UAs want to implement it) alongside the font properties; they all effectively just inherit through to the text rather than applying to ::marker.
    • Add text-align: end !important; text-indent: 0 !important; hanging-punctuation: none !important to the UA style sheet of any browser that supports those properties on ::marker.
    • Add text-transform: none to the UA rule for ::marker.
    • Don't add word-spacing or letter-spacing resets to the UA rule for ::marker.

    I'm not entirely sure about the last two. @dauwhe ?

  4. faceless2 commented on Dec 6, 2019

    @faceless2
    Author

    We have to remember that this resetting would be applied to inside markers as well as outside ones,

    The inability to distinguish between inside and outside markers is consistently making the process of styling them (both in terms which properties apply, and what their defaults are) quite a bit more complicated. Would something like ::marker:inside and ::marker:outside be worth considering?

  5. Loirooriol commented on Dec 7, 2019

    @Loirooriol
    Contributor

    We should also consider text breaking properties. For example, it's not clear if overflow-wrap may affect outside markers, but definitely it can affect inline ones. As usual,

    • Firefox obeys inherited overflow-wrap when ::marker has a non-normal content. Otherwise the marker is unbreakable.
    • Chromium obeys inherited overflow-wrap with LayoutNG. Otherwise the marker is unbreakable.
  6. frivoal commented on Dec 9, 2019

    @frivoal
    Collaborator

    The inability to distinguish between inside and outside markers is consistently making the process of styling them (both in terms which properties apply, and what their defaults are) quite a bit more complicated. Would something like ::marker:inside and ::marker:outside be worth considering?

    I suspect you're right, and that we need something like this. Whether we actually expose it is an interesting question, but given that inside markers and outside markers seem call for different behaviors, effectively that's the model we're using. Given that this doesn't introduce any selector-styling loop shenanigans, I suspect we should make it explicit and expose it.

    And from there, it looks like quite a few of the resets (with or without !important) should be on ::marker:outside rather than on ::maker, as the inside case seems to need much less magic.

  7. Loirooriol commented on Dec 9, 2019

    @Loirooriol
    Contributor

    Note that adding :inside and :outside, especially if they are exposed, would close the door to supporting list-style-position in ::marker in the future, since it could introduce a circularity. https://wiki.csswg.org/faq#selectors-that-depend-on-layout

    If display: marker or position: marker are reintroduced, these properties could be affected too.

  8. frivoal commented on Dec 9, 2019

    @frivoal
    Collaborator

    Not really, since list-style-position needs to be applied to the list item to take effect, not the marker. So there's no loop. Applying list-style-position on the ::marker would work just fine if the marker itself was a list item, and then it would change the position of ::marker::marker.

    If we don't allow having markers on markers, then it is only natural than applying list-style-position on the marker itself would do nothing.

  9. Loirooriol commented on Dec 9, 2019

    @Loirooriol
    Contributor

    Sure, I mean that for example Chromium legacy reads the list-style-position of the marker itself (LayoutListMarker) instead of the list item. That's a valid interpretation because list-style-position inherits and is not syntactically supported in ::marker. And it's not unreasonable for the ::marker to obey its own list-style-position instead of the list item one. This interpretation won't be possible once we allow all properties in ::marker if we have :inside and :outside.

  10. Loirooriol commented on Dec 11, 2019

    @Loirooriol
    Contributor

    Exposing :inside/:outside could make :has() impossible, or at least prevent it from containing pseudo-elements

    :has(::marker:outside) { list-style-position: inside }
  11. faceless2 commented on Dec 11, 2019

    @faceless2
    Author

    As in, that selector would result in the CSS oscillating between two states? True, but I can also think of:

    :not(:has(::marker)) { display: list-item }
    :has(::marker) { display: block }

    I can't get :has(::marker) to match at all, so I've not idea if this sort of loop is already covered. Preventing it is obviously important, but I don't think it's a problem specific to :inside / :outside.

  12. Loirooriol commented on Dec 11, 2019

    @Loirooriol
    Contributor

    @faceless2 There is no circularity with ::marker alone, since it exists even with display: block. See #1793 (comment)

    RESOLVED: marker exists on all elements, on ::before and on ::after but no box unless it's display: list-item

  13. faceless2 commented on Dec 11, 2019

    @faceless2
    Author

    Ah, very true. I'll try to come up with another one :-)

    Edit: not sure I can actually. So yes, I agree that setting list-style-position as in your example would cause an issue, and it's probably a new one. Whether it's enough on its own to rule out :inside / :outside is the question.

  14. frivoal commented on Jan 7, 2020

    @frivoal
    Collaborator

    While we're considering which properties apply or don't, and reset or don't, it seems that the text-decoration properties in general, and the text-decoration-skip family of properties in particular should apply. (initially raised in #843).

  15. 37 remaining items

  16. added
    css-lists-3
    and removed
    css-pseudo-4
    on Dec 30, 2020
  17. fantasai commented on Dec 30, 2020

    @fantasai
    Collaborator

    Ok, pushed some wording changes:

    Let me know if this is workable, or if the wording needs additional tweaking. CC @tabatkins for review.

    As for whether this is the right approach or if we should go ahead and define marker layout...
    I note @MatsPalmgren’s objection and insistence that we should just define outside marker layout, but as @faceless2 noted “the devil is in those details”. I've worked on a number of layout specs, and I'm familiar with the range of issues that have been raised against outside marker layout over the years and I am quite sure this is not a trivial project. Should we do this? Yes. But in the next level, because the rest of this spec is comparatively done, and we should get it wrapped up and sent to CR.

    If anyone wants to start work on the outside marker layout project right now, I invite you to start a css-lists-4 delta ED in the repository and start drafting it up. I can't prioritize it right now personally, but this isn't to say that we shouldn't be working on it. But I think it will take 1-3 years, not 1-3 months, before we shake out all the issues and that's with someone actively working on it. Which is why I don't want to hold up everything else in css-lists-3 (most of which is already shipping) to wait for it.

    In the meantime, I think it's best to disable most styling of ::marker until we can work out what exactly it means, so that authors don't build a dependency on particular behaviors that we end up wanting to change as we work through all the outside marker layout issues. If you disagree on this point and would like to argue for letting whatever interop and Web-compat constraints fall out of authors exploiting various layout properties on your implementations dictate what we're able to define for outside marker layout going forward, please make a cogent argument to that effect. But I think it's safest if such properties don't have any effect until we are agreed on what exactly that effect will be.

  18. betagoo commented on Sep 26, 2026

    @betagoo

    Please, add possibility to set position: absolute, and transform: translateY translateX like ::before has.

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

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      Sponsor
      SponsoredKunjungi sekarang
      Promo