Repository navigation
Description
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:
| property | applicability to markers |
|---|---|
| hanging-punctuation | probably n/a |
| hyphens | n/a |
| letter-spacing | ? |
| line-break | n/a |
| overflow-wrap | n/a |
| tab-size | tabs in markers? |
| text-align-* | ? |
| text-indent | ? |
| text-justify | will depend on text-align |
| text-transform | ? |
| white-space | already covered |
| word-break | n/a |
| word-spacing | ? |
| word-wrap | n/a |
| word-wrap | n/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:
| property | Firefox | Chrome | Safari |
|---|---|---|---|
| letter-spacing | N | Y | Y |
| word-spacing | N | Y | Y |
| text-indent | N | N | N |
| text-align | Y | N | N |
| text-transform | N | Y | N |
| text-shadow | N | Y | N |
| hanging-punctuation | N | - | - |
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
Loirooriol commentedon Dec 6, 2019
There is also #4206 about
text-transform.Note that not even Chromium legacy and Chromium LayoutNG are interoperable.
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 incontentmarkers but not in legacy markers (nsBulletFrame).Note Chromium LayoutNG does support it, but maybe not like you expected? If you use
content: 'ab\a c'andwhite-space: pre, withtext-align: leftthecappears below thea, and withtext-align: rightit appears below theb.In general I would lean towards not resetting properties unless strictly necessary.
faceless2 commentedon Dec 6, 2019
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.
fantasai commentedon Dec 6, 2019
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-alignandtext-indentsince 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, settingtext-align: end !important; text-indent: 0 !important; hanging-punctuation: none !importantin 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-shadowinherit from the list item element the same ascolor. I suspect it's better to block inheritance oftext-transformby default viatext-transform: none, since casing is often used to distinguish list items. Wrt resettingword-spacingandletter-spacingI'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:
word-spacing,letter-spacing,text-shadow, and maybetext-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.text-align: end !important; text-indent: 0 !important; hanging-punctuation: none !importantto the UA style sheet of any browser that supports those properties on ::marker.text-transform: noneto the UA rule for ::marker.word-spacingorletter-spacingresets to the UA rule for ::marker.I'm not entirely sure about the last two. @dauwhe ?
faceless2 commentedon Dec 6, 2019
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:insideand::marker:outsidebe worth considering?Loirooriol commentedon Dec 7, 2019
We should also consider text breaking properties. For example, it's not clear if
overflow-wrapmay affect outside markers, but definitely it can affect inline ones. As usual,overflow-wrapwhen ::marker has a non-normalcontent. Otherwise the marker is unbreakable.overflow-wrapwith LayoutNG. Otherwise the marker is unbreakable.frivoal commentedon Dec 9, 2019
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:outsiderather than on::maker, as the inside case seems to need much less magic.Loirooriol commentedon Dec 9, 2019
Note that adding
:insideand:outside, especially if they are exposed, would close the door to supportinglist-style-positionin ::marker in the future, since it could introduce a circularity. https://wiki.csswg.org/faq#selectors-that-depend-on-layoutIf
display: markerorposition: markerare reintroduced, these properties could be affected too.frivoal commentedon Dec 9, 2019
Not really, since
list-style-positionneeds to be applied to the list item to take effect, not the marker. So there's no loop. Applyinglist-style-positionon the::markerwould 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.
Loirooriol commentedon Dec 9, 2019
Sure, I mean that for example Chromium legacy reads the
list-style-positionof the marker itself (LayoutListMarker) instead of the list item. That's a valid interpretation becauselist-style-positioninherits and is not syntactically supported in ::marker. And it's not unreasonable for the ::marker to obey its ownlist-style-positioninstead of the list item one. This interpretation won't be possible once we allow all properties in ::marker if we have:insideand:outside.Loirooriol commentedon Dec 11, 2019
Exposing
:inside/:outsidecould make:has()impossible, or at least prevent it from containing pseudo-elementsfaceless2 commentedon Dec 11, 2019
As in, that selector would result in the CSS oscillating between two states? True, but I can also think of:
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.Loirooriol commentedon Dec 11, 2019
@faceless2 There is no circularity with ::marker alone, since it exists even with
display: block. See #1793 (comment)faceless2 commentedon Dec 11, 2019
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-positionas 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 / :outsideis the question.frivoal commentedon Jan 7, 2020
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).
37 remaining items
[css-pseudo] Support 'line-height' property in ::marker
[css-pseudo] Support 'line-height' property in ::marker
Bug 1668270 [wpt PR 25886] - [css-pseudo] Support 'line-height' prope…
Bug 1668270 [wpt PR 25886] - [css-pseudo] Support 'line-height' prope…
[css-lists-3] Tweak general restrictions on ::marker to be more preci…
fantasai commentedon Dec 30, 2020
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.
Bug 1668270 [wpt PR 25886] - [css-pseudo] Support 'line-height' prope…
[css-pseudo] Reflect in computed style that text-indent doesn't apply…
betagoo commentedon Sep 26, 2026
Please, add possibility to set position: absolute, and transform: translateY translateX like ::before has.