-
Notifications
You must be signed in to change notification settings - Fork 133
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
stroke-width initial value must include units #529
Comments
The stroke-width syntax should actually be But I don't see a problem with making the initial value have units, since the computed value is always converted to absolute length anyway. |
Confirmed support for plain numbers in all browsers. There are a couple of implementation bugs: Only Safari changes "10" to "10px" when serializing. Only Firefox gives "10" as the computed style. Neither has these bugs for line-height. |
I’m not sure what you mean by “plain numbers are valid in CSS properties” but as far as the CSS
It’s unsurprising that browsers accept and process unit-less numbers in the value. The issue here isn’t about the processing behavior/requirements in browsers; instead it’s about the document-conformance requirements — the authoring rules. And naively I’d assume that a goal here is to be consistent with how the CSS specs define the document-conformance requirements for CSS |
In SVG 1 and SVG 2, a unitless number is always allowed as a length in a presentation attribute (even for old CSS properties like SVG 1 also always allowed a unitless number as a length "for properties defined in SVG", extending the CSS definition. In SVG 2, we made these syntax options explicit for properties defined in SVG 1 (changing But |
(The "relevant CSS specs" are the same spec at different URLs, and both were created by copy & pasting the error from SVG 2!) |
We also need to validate the initial value in browsers. Maybe it is |
We might need to add some tests and wording for the computed value and number as well. |
When 'initial' is specified, all browsers give 'initial' as serialized value and '1px' as computed value. |
ah, I see — thanks So then, can somebody raise an issue for this at https://github.com/w3c/fxtf-drafts/labels/fill-stroke-3 — or maybe better yet, a pull request there? (I’d offer to do it myself but I think it would be better done by somebody who’s familiar with the provenance.) The reason I care about this is that the CSS validator currently reports an error for unit-less values of the CSS But if https://drafts.fxtf.org/fill-stroke/#stroke-width can be updated to allow |
I'm not sure why we should care about the CSS validator. It doesn't track the specifications, doesn't handle svg in html5 well, and gives more false negatives than useful information. |
When was the last time you tried it? I’ve actually put many hours of work this year into bringing it up to date, and @ylafon has put many more into it than I ever will. You and @tabatkins might want to take a look through https://github.com/w3c/css-validator/commits/master It’s pretty disheartening to have a couple of people in positions of leadership in the CSS WG expressing (and thumbs-upping) those kinds of sentiments. It’s not constructive, it doesn’t help the conversation here in any way — and it’s personally really demoralizing to me, as one of the people who’s put significant effort this year into improving the CSS validator. You really bummed me out with that. Maybe you figure @ylafon and I should just quit caring about the CSS validator too? And quit trying to improve it? |
I will as part of #534. For stroke-width we need to update two specs, and raise two browser bugs with a WPT. But first I'll investigate if there are also more properties affected. |
Thanks! |
The SVG 1.1 and 2.0 specs only allow a single value for stroke-width: The CSS Fill and Stroke Module Level 3 draft indicates multiple values are allowed for stroke-width
A hash mark (#) indicates that the preceding type, word, or group occurs one or more times Hard to think of any way to use multiple values for stroke-width - is this a typo? |
@dd8 Not a typo. The new spec allows multiple, layered strokes. So you could draw a thin stroke in one color on top of a thick stroke in another color. Or a dashed stroke on top of a solid-colored stroke. The feature was initially proposed for SVG 2, but was deferred. |
Fixed, closing. |
We now have WPTs and I have raised the two browser bugs: |
At https://svgwg.org/svg2-draft/painting.html#StrokeWidthProperty, the initial value must not be just
1
; instead the units must be explicitly included — so it needs to be1px
.That’s per the chain of syntax requirements from https://drafts.csswg.org/css-values-4/#typedef-length-percentage to https://drafts.csswg.org/css-values-4/#length-value to https://drafts.csswg.org/css-values-4/#dimension that the SVG spec normative includes by reference (due to citing https://www.w3.org/TR/css-values/#typedef-length-percentage) — which indicate that a
<length-percentage>
value must include units if it’s a length.See also https://drafts.fxtf.org/fill-stroke/#stroke-width, which correctly has the initial value as
1px
instead of just1
.The text was updated successfully, but these errors were encountered: