You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[css-lists] canonical property order of list-style. #2624
list-style-type accepts an arbitrary identifier via <counter-style>, and thus should be last, since it can overlap with values of list-style-position.
It is a bit confusing. A counter-style name is a custom identifier, and custom identifiers are defined like "if it can mess with other identifiers, it is invalid". There is the following at:
Note: When designing grammars with <custom-ident>, the <custom-ident> should always be "positionally unambiguous", so that it’s impossible to conflict with any keyword values in the property.
Note: Note that <custom-ident> also automatically excludes the CSS-wide keywords. In addition, some names, like inside, are valid as counter style names, but conflict with the existing values of properties like list-style, and so won’t be usable there.
So inside is a valid counter-style name, but is "not usable" in the shorthand. That sounds a lot like an invalid <custom-ident>. The "Counter Styles" specification should be changed to declare inside and outside invalid counter-style names.
Hmm, the problem with that kind of thing is that it prevents you from adding keywords to list-style-position without potentially breaking code...
Plus now you need to also make it invalid in the longhand, or then not serializing it in the shorthand.
Seems strictly worse and more complicated than swapping the values to me...
FF definitely allows you to write list-style-type: inside, and similar. Seems like Blink / WebKit don't implement the <counter-style-name> bits, does any other browser?
Hmm, the problem with that kind of thing is that it prevents you from adding keywords to list-style-position without potentially breaking code...
But inside and outside are there since the beginning of the shorthand, and counter-styles are a less established feature AFAIR.
Seems strictly worse and more complicated than swapping the values to me...
Not mutually exclusive. Your proposal make things a bit more deterministic, but still potentially confusing to users. I do not have a strong opinion in favour or against it (like if that mattered), but still think that banning those two values would be a good idea.
So far, I have been thinking here in terms of problems when parsing an author-specified shorthand, however when it concerns serializing:
Otherwise serializing the property and reparsing could generated different results.
Serialization should involve a sanity check of the individual values, that's what I do in my code (admittedly not for all shorthands) and I was assuming that browser people does the same. For example, in tests with real-world sites I found frequent cases where url() PNG images were set to background-color properties, which then bombs a blindly-produced shorthand. So my code checks for those cases.
FF definitely allows you to write list-style-type: inside, and similar.
That should not be a problem if you do not produce a shorthand with it (you could produce a shorthand plus the problematic property:value, or keep all the longhands in the serialization). Perhaps that should be the first thing to check out here.
So, we have a precedent for putting <custom-ident> at the end of shorthand to avoid conflicting with other keywords, which is animation. That case is also mentioned in the note of css-values spec as an example of designing "positionally unambiguous" grammar with <custom-ident>.
Given that, I tend to think we should change css-counter-styles to remove that note and change the canonical order of list-style shorthand.
I'd be against reordering of the list-style shorthand as a solution.
It's currently defined as <list-style-type> || <list-style-position> || <list-style-image>, which allows free reordering of the terms.
If you want to change it to remove the ambiguity introduced by allowing list-style-type to match "inside" or "outside", you're still going to have to allow any order except when the type is called "inside" or "outside". So "list-style: decimal inside" will remain valid, but "list-style: outside inside" where the counter is called "outside" is not.
First, the grammar is going to more complicated then necessary; something like [<list-style-style-type-except-inside-outside> || <list-style-position> || <list-style-image>] | [<list-style-position || <list-style-image>] [inside | outside]?, and that's discounting the special handling that will be required to interpret "none" correctly.
Second, even with an unambiguous grammar it will remain confusing. An author seeing "list-style: inside outside" will have no idea what is going on without consulting the spec.
Given so few browsers implement @counter-style at this stage, personally I feel the best solution is disallowing "inside" and "outside" as counter names. We already do it with "none" so there's precedent. Prevent authors from shooting themselves in the foot.
The second best solution would be not allowing them to be referenced from the list-style shorthand property. As pointed out above, there is no ambiguity except in the list-style shorthand property.
There are plenty of property shorthands that restrict ordering: font: italic 300px bold is referencing a font called "bold", there's no ambiguity.
But if that is going to be the solution for list-style then it has to be done without breaking the existing syntax, which allows the list-style-type as the first item in the list.
By "this syntax", I mean <list-style-position> || <list-style-image> || <list-style-type> for the shorthand, and thus we propose to change the spec to adopt this canonical order.
font isn't a particularly relevant example; it has to have a font-family in it, and that value has to be last, so it's generally "positionally unambiguous".
(There are exceptions to this; if the font-family is "Bold New Font", then font: italic 300px Bold New Font could potentially be parsed as a bold version of "New Font" or as a normal version of "Bold New Font". But it's usually true, unlike the animation example.)
FWIW, Firefox has been shipping the feature using this syntax for several years, and I don't think I heard any breakage caused by this change.
I'm extremely convinced by this argument and thus am fine with it. ^_^
@upsuper I was just doing some testing in Firefox and Chrome, and have a further question.
none is already a valid predefined keyword for both 'list-style-type' and 'list-style-image'. Per spec, you have to treat it as being specified for whichever property doesn't otherwise have something specified. That is, in the following:
#foo should show a decimal, and #bar should show a pony.
This conflicts with the suggested treatment of custom list-style-type, which should treat the #bar rule as invalid (as the none gets consumed by 'list-style-image', then you can't match the url() against the remaining grammar terms). So you should get decimal/disc if we're being consistent.
Both Firefox and Chrome disagree with this, in different ways - Firefox implements the current spec, showing decimal/pony. Chrome does the opposite, showing disc/pony. (I presume it just consumes greedily, and gives list-style-type priority, rather than the opposite.) Is this behavior change okay?
Note: The <counter-style> values of list-style-type can also create grammatical ambiguities. As such values are ultimately <custom-ident> values, the parsing rules in [CSS-VALUES-3] apply.
The note seems rather vague to me, whereas animation is more explicit. And serializing also requires to output an explicit outside for list-style-position when list-style-type is inside.
Activity
carlosame commentedon May 9, 2018
Hi Emilio,
It is a bit confusing. A counter-style name is a custom identifier, and custom identifiers are defined like "if it can mess with other identifiers, it is invalid". There is the following at:
https://www.w3.org/TR/css3-values/#identifier-value
Then, at:
https://www.w3.org/TR/css-counter-styles-3/#at-ruledef-counter-style
you have this:
So
insideis a valid counter-style name, but is "not usable" in the shorthand. That sounds a lot like an invalid<custom-ident>. The "Counter Styles" specification should be changed to declareinsideandoutsideinvalid counter-style names.emilio commentedon May 9, 2018
Hmm, the problem with that kind of thing is that it prevents you from adding keywords to list-style-position without potentially breaking code...
Plus now you need to also make it invalid in the longhand, or then not serializing it in the shorthand.
Seems strictly worse and more complicated than swapping the values to me...
FF definitely allows you to write
list-style-type: inside, and similar. Seems like Blink / WebKit don't implement the<counter-style-name>bits, does any other browser?cc @upsuper
carlosame commentedon May 9, 2018
But
insideandoutsideare there since the beginning of the shorthand, and counter-styles are a less established feature AFAIR.Not mutually exclusive. Your proposal make things a bit more deterministic, but still potentially confusing to users. I do not have a strong opinion in favour or against it (like if that mattered), but still think that banning those two values would be a good idea.
carlosame commentedon May 9, 2018
Apparently not, according to browser compatibility table at:
https://developer.mozilla.org/en-US/docs/Web/CSS/@counter-style
And my latest Chrome does not support the demo at:
https://mdn.github.io/css-examples/counter-style-demo/
carlosame commentedon May 10, 2018
So far, I have been thinking here in terms of problems when parsing an author-specified shorthand, however when it concerns serializing:
Serialization should involve a sanity check of the individual values, that's what I do in my code (admittedly not for all shorthands) and I was assuming that browser people does the same. For example, in tests with real-world sites I found frequent cases where url() PNG images were set to background-color properties, which then bombs a blindly-produced shorthand. So my code checks for those cases.
That should not be a problem if you do not produce a shorthand with it (you could produce a shorthand plus the problematic property:value, or keep all the longhands in the serialization). Perhaps that should be the first thing to check out here.
upsuper commentedon May 11, 2018
So, we have a precedent for putting
<custom-ident>at the end of shorthand to avoid conflicting with other keywords, which isanimation. That case is also mentioned in the note of css-values spec as an example of designing "positionally unambiguous" grammar with<custom-ident>.Given that, I tend to think we should change css-counter-styles to remove that note and change the canonical order of
list-styleshorthand.cc @tabatkins
faceless2 commentedon May 31, 2018
(@emilio , thanks for the cross-reference, somehow I missed this issue when I opened #2724)
The example I filed in the other issue I think is worth reproducing here for clarity
I'd be against reordering of the list-style shorthand as a solution.
It's currently defined as
<list-style-type> || <list-style-position> || <list-style-image>, which allows free reordering of the terms.If you want to change it to remove the ambiguity introduced by allowing
list-style-typeto match "inside" or "outside", you're still going to have to allow any order except when the type is called "inside" or "outside". So "list-style: decimal inside" will remain valid, but "list-style: outside inside" where the counter is called "outside" is not.First, the grammar is going to more complicated then necessary; something like
[<list-style-style-type-except-inside-outside> || <list-style-position> || <list-style-image>] | [<list-style-position || <list-style-image>] [inside | outside]?, and that's discounting the special handling that will be required to interpret "none" correctly.Second, even with an unambiguous grammar it will remain confusing. An author seeing "list-style: inside outside" will have no idea what is going on without consulting the spec.
Given so few browsers implement @counter-style at this stage, personally I feel the best solution is disallowing "inside" and "outside" as counter names. We already do it with "none" so there's precedent. Prevent authors from shooting themselves in the foot.
The second best solution would be not allowing them to be referenced from the list-style shorthand property. As pointed out above, there is no ambiguity except in the
list-styleshorthand property.upsuper commentedon May 31, 2018
I've mentioned before, there is precedent. The syntax of
animationiswhich should allow free reordering of the terms, but
<keyframes-name>is always parsed the latest, and thus something likeease easeis not ambiguous.faceless2 commentedon May 31, 2018
There are plenty of property shorthands that restrict ordering:
font: italic 300px boldis referencing a font called "bold", there's no ambiguity.But if that is going to be the solution for
list-stylethen it has to be done without breaking the existing syntax, which allows thelist-style-typeas the first item in the list.upsuper commentedon May 31, 2018
FWIW, Firefox has been shipping the feature using this syntax for several years, and I don't think I heard any breakage caused by this change.
upsuper commentedon May 31, 2018
By "this syntax", I mean
<list-style-position> || <list-style-image> || <list-style-type>for the shorthand, and thus we propose to change the spec to adopt this canonical order.tabatkins commentedon May 31, 2018
fontisn't a particularly relevant example; it has to have a font-family in it, and that value has to be last, so it's generally "positionally unambiguous".(There are exceptions to this; if the font-family is "Bold New Font", then
font: italic 300px Bold New Fontcould potentially be parsed as a bold version of "New Font" or as a normal version of "Bold New Font". But it's usually true, unlike theanimationexample.)I'm extremely convinced by this argument and thus am fine with it. ^_^
tabatkins commentedon May 31, 2018
@upsuper I was just doing some testing in Firefox and Chrome, and have a further question.
noneis already a valid predefined keyword for both 'list-style-type' and 'list-style-image'. Per spec, you have to treat it as being specified for whichever property doesn't otherwise have something specified. That is, in the following:#foo should show a decimal, and #bar should show a pony.
This conflicts with the suggested treatment of custom list-style-type, which should treat the #bar rule as invalid (as the
nonegets consumed by 'list-style-image', then you can't match theurl()against the remaining grammar terms). So you should get decimal/disc if we're being consistent.Both Firefox and Chrome disagree with this, in different ways - Firefox implements the current spec, showing decimal/pony. Chrome does the opposite, showing disc/pony. (I presume it just consumes greedily, and gives list-style-type priority, rather than the opposite.) Is this behavior change okay?
71 remaining items
Bug 1564640 [wpt PR 17526] - CSS: list-style shorthand matches update…
Bug 1564640 [wpt PR 17526] - CSS: list-style shorthand matches update…
Bug 1564640 [wpt PR 17526] - CSS: list-style shorthand matches update…
Bug 1564640 [wpt PR 17526] - CSS: list-style shorthand matches update…
Bug 1564640 [wpt PR 17526] - CSS: list-style shorthand matches update…
fantasai commentedon Jul 8, 2020
@upsuper Added a note,
[css-lists-3] Add a note pointing at the custom-ident parsing rules f…
cdoublev commentedon Sep 18, 2023
The note seems rather vague to me, whereas
animationis more explicit. And serializing also requires to output an explicitoutsideforlist-style-positionwhenlist-style-typeisinside.Bug 1564640 [wpt PR 17526] - CSS: list-style shorthand matches update…