Re: [csswg-drafts] [css-text-decor] Rounding of text-decoration-thickness (#12696)

The CSS Working Group just discussed `[css-text-decor] Rounding of text-decoration-thickness`, and agreed to the following:

* `RESOLVED: Snap text-decoration-thickness as a border width (https://drafts.csswg.org/css-values-4/#snap-a-length-as-a-border-width) at used-value time`

<details><summary>The full IRC log of that discussion</summary>
&lt;ydaniv> emilio: this is about how text-decoratoin-thikness is rounded<br>
&lt;ydaniv> ... seems wierd to have a different algo<br>
&lt;TabAtkins> from-font<br>
&lt;ydaniv> ... also there's the whole auto vs. from-font<br>
&lt;ydaniv> ... should we do it at compute value time or used value time, is the question<br>
&lt;kizu> q+<br>
&lt;Rossen3> ack dbaron<br>
&lt;ydaniv> dbaron: this is a space of stuff where I have stong opinion, not really CHrome position<br>
&lt;ydaniv> ... I think I agree that we do want something that causes thikness to be consistent<br>
&lt;ydaniv> ... with borders we align other things, and need to have it consistent, so that top and bottom edges snap, and also layout concerns<br>
&lt;ydaniv> ... if someone has a specific text decor thikness you have to something to prevent [missed]<br>
&lt;fantasai> +1 to dbaron<br>
&lt;Rossen3> ack kizu<br>
&lt;dbaron> s/strong opinion/strong opinions from back when I worked on this stuff in Gecko/<br>
&lt;ydaniv> kizu: wanted to add about rounding of text decor, maybe also add some min value, not 0<br>
&lt;dbaron> s/prevent [missed]/prevent the text decoration from being a different apparent thickness on different lines as a result of shifts in the subpixel positions of the lines/<br>
&lt;ydaniv> ... it's a very common case when you add value based on font-size, it's easy to make it small enough, so when zooming or changing size it becomes close to 0<br>
&lt;emilio> q+ to say that is exactly what borders do ;)<br>
&lt;ydaniv> ... but this has a strong meaning<br>
&lt;ydaniv> ... so common practie is to wrap with clamp and a min value, so would be nice to introduce a way to clamp and not introduce a footgun<br>
&lt;Rossen3> ack emilio<br>
&lt;Zakim> emilio, you wanted to say that is exactly what borders do ;)<br>
&lt;dbaron> (btw, for borders the "affects layout" aspects mean that the snapping needs to affect computed values, I think... whereas for text decorations I don't think computed versus used mattters as much)<br>
&lt;ydaniv> emilio: that is exactly what borders do, any non 0 value is rounded up to 1px<br>
&lt;ydaniv> ... my proposal fixes that<br>
&lt;fantasai> dbaron, I don't think affecting layout needs to affect computed value<br>
&lt;ydaniv> dbaron: I agree it should be the same, but not necessarily have to match borders<br>
&lt;ydaniv> emilio: even if we need to compute at used value time....<br>
&lt;ydaniv> fantasai: yes, we should floor to 1 px, unless specifying 0<br>
&lt;dbaron> (or at least I *think* it's computed value time... not enirely sure)<br>
&lt;ydaniv> ... not convinced about the think with borders<br>
&lt;ydaniv> ... for borders with layout calc you need to snap it<br>
&lt;ydaniv> emilio: there's an issue with CSSOM API to get the correct value<br>
&lt;ydaniv> ... for borders, not proposing to change it, I agree that we can make it used value time<br>
&lt;Rossen3> q?<br>
&lt;ydaniv> fantasai: don't have a strong opinion on used/computed, just need to specify that we should snap on thikness of 1 px, and align on the grid when drawn<br>
&lt;Rossen3> ack fantasai<br>
&lt;fantasai> s/1 px/1 device pixel/<br>
&lt;ydaniv> Rossen3: other feedback to emilio?<br>
&lt;lea> q?<br>
&lt;ydaniv> fantasai: also snap to device pixel<br>
&lt;Rossen3> ack dbaron<br>
&lt;ydaniv> dbaron: all arguments here also apply to text-decor-offset<br>
&lt;ydaniv> fantasai: not sure about that, if the offset is on the pixel you want to snap to 0<br>
&lt;lea> q+<br>
&lt;ydaniv> dbaron: you're right that is different, but the thing why we want to snap still applies<br>
&lt;emilio> https://drafts.csswg.org/css-values-4/#snap-a-length-as-a-border-width is pretty explicitly device pixels<br>
&lt;fantasai> We're snapping to device pixels, not CSS px units<br>
&lt;ydaniv> fantasai: it's that you have to draw the line on the pixel grid, that calc should be done when you figure out where to draw<br>
&lt;Rossen3> ack lea<br>
&lt;ydaniv> leaverou: why are we rounding at all?<br>
&lt;ydaniv> fantasai: because you don't want the underline to be not drawn at all, and you want it to be on the correct position on the pixel grid<br>
&lt;ydaniv> ... you wan't it to be consistent<br>
&lt;TabAtkins> yup, pixel grid is very visually important for the rendering of these thin lines<br>
&lt;ydaniv> dbaron: another way of saying it is that the position where we draw things is [missed]<br>
&lt;ydaniv> ... the problem is that if there are 2 things that occur in multiple positions, you need the distance to be consistent<br>
&lt;ydaniv> ... otherwise snapping can happen at different subpixel positions<br>
&lt;emilio> q+<br>
&lt;Rossen3> ack emilio<br>
&lt;dbaron> s/is [missed]/is based on snapping each edge to device pixels<br>
&lt;ydaniv> emilio: wanted to propose a resolution, fine to do it at use value time, it's always nicer for these things<br>
&lt;ydaniv> fantasai: sounds reasonable<br>
&lt;kbabbitt> +1<br>
&lt;ydaniv> Rossen3: we have a proposal...<br>
&lt;ydaniv> jfkthame: so if we round done for text decor, is that what we want as well?<br>
&lt;oriol> So auto and from-font will also be snapped, right?<br>
&lt;ydaniv> emilio: for borders it creates overflow<br>
&lt;fantasai> yes<br>
&lt;ydaniv> dbaron: I agree we don't need that aspect here<br>
&lt;emilio> PROPOSED: Snap text-decoration-thickness as a border width (https://drafts.csswg.org/css-values-4/#snap-a-length-as-a-border-width) at used-value time<br>
&lt;ydaniv> fantasai: I think for text to look more thick [missed]<br>
&lt;ydaniv> Rossen3: objections?<br>
&lt;fantasai> snapping down is probably the right call here, too, since it will obfuscate the text less<br>
&lt;ydaniv> RESOLVED: Snap text-decoration-thickness as a border width (https://drafts.csswg.org/css-values-4/#snap-a-length-as-a-border-width) at used-value time<br>
&lt;lea> q+<br>
&lt;ydaniv> Rossen3: dbaron please open separate issue on grid alignment<br>
&lt;Rossen3> ack lea<br>
&lt;emilio> q+<br>
&lt;ydaniv> lea: not objecting, but concerned that CSS is the wrong place to worry about rasterization, why are underlines special?<br>
&lt;ydaniv> ... if it's so thin that it becomes invisible, so why are doing this at all? would like more ppl to look at it<br>
&lt;oriol> See https://github.com/servo/servo/issues/29668. We had to snap auto in Servo, or otherwise we got no underline<br>
&lt;ydaniv> ... have seen snapping to 2px problematic in other features<br>
&lt;ydaniv> dbaron: to the begining of CSS, if it had this wierd combo of doing some rendering in some things and not others<br>
&lt;Rossen3> ack dbaron<br>
&lt;ydaniv> ... without transforms we don't do antialias at edge of box<br>
&lt;ydaniv> ... when you do things like %s sizing you get blurry edges<br>
&lt;ydaniv> ... for things like borders we decided that boxes and layout stuff, we layout and snap the edges, but for borders we wanted consistent thickness<br>
&lt;Rossen3> ack emilio<br>
&lt;ydaniv> emilio: wanted to give shorted answer...<br>
&lt;fantasai> Nobody wants fuzzy lines, basically<br>
&lt;dbaron> s/some rendering/subpixel rendering/<br>
</details>


-- 
GitHub Notification of comment by css-meeting-bot
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/12696#issuecomment-3638291149 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Wednesday, 10 December 2025 17:52:30 UTC