Skip to content

[css-borders] Interaction between border-shape and other border properties #14149

Open

Description

@LeaVerou

https://drafts.csswg.org/css-borders/#border-shape

Currently, interaction with border-width and border-color is basically:

  • Figure out the relevant side
  • Use the border-width and border-color from that for the stroke
  • Throw away all other values but still occupy the same space as they would if this were not using border-shape
  • border-style isn't even part of the equation. Effectively, any value other than solid or none has no effect. There's no way to use a dashed or dotted stroke, even though that's perfectly well defined in SVG and makes perfect sense conceptually.

This is …not great. 😕 From the author's point of view, many of these are interactions that should work, though not all are equally valuable:

  • border-width is the worst one as it affects the box model. If the relevant side is smaller than the max width, surrounding content will overlap the border. If it's larger, there will be pointless empty space. Plus, many of the use cases for two shapes are actually one shape with border-width actually working.
  • Dropping side colors is suboptimal, but I don't think it comes up much in practice. Nobody wants these hard angular transitions anyway.
  • Not all border-styles are equal. I think it's fine to ignore inset, outset, groove, ridge since they’re effectively legacy. But dashed, dotted, double make perfect sense.

Additionally, interactions with other planned features either in the same spec or resolved to be added to it are underspecified or not specified at all, such as:

I know that the general problem of variable stroke width is considered hard, but do we need to solve the general problem? What if we introduce constraints about the type of shape that can be used? E.g. no self-intersection, max curvature bound, no cusps etc. We could even start strict and relax them over time with no API changes.

Alternatively (and probably more realistically), can we drop the relevant side rule and treat it as an error (at ??? time) if the border properties are not compatible? Then we can define reasonable interactions in the future without compat getting in the way.

cc @fantasai @SebastianZ @noamr

Activity

  1. noamr commented on Jul 9, 2026

    @noamr
    Collaborator
  2. changed the title [-][css-borders] Need to define the interaction between `border-shape` and `border-width`/`border-color`[/-] [+][css-borders] Interaction between `border-shape` and other border properties[/+] on Jul 10, 2026
  3. LeaVerou commented on Jul 10, 2026

    @LeaVerou
    MemberAuthor

    It's specified here: drafts.csswg.org/css-borders-4#border-shape-syntax

    Thanks, I had missed some of that somehow, updated the title/OP!

  4. noamr commented on Jul 10, 2026

    @noamr
    Collaborator

    https://drafts.csswg.org/css-borders/#border-shape

    Currently, interaction with border-width and border-color is basically:

    • Figure out the relevant side
    • Use the border-width and border-color from that for the stroke
    • Throw away all other values but still occupy the same space as they would if this were not using border-shape
    • border-style isn't even part of the equation. Effectively, any value other than solid or none has no effect. There's no way to use a dashed or dotted stroke, even though that's perfectly well defined in SVG and makes perfect sense conceptually.

    Note that border-style rendering is not specified regardless of border-shape. Rendering dotted or dashed borders according to border-style would be spec compliant.

    This is …not great. 😕 From the author's point of view, many of these are interactions that should work, though not all are equally valuable:

    • border-width is the worst one as it affects the box model. If the relevant side is smaller than the max width, surrounding content will overlap the border. If it's larger, there will be pointless empty space. Plus, many of the use cases for two shapes are actually one shape with border-width actually working.

    Yea that's why we suggested to be able to override this with a stroke-like property.

    • Dropping side colors is suboptimal, but I don't think it comes up much in practice. Nobody wants these hard angular transitions anyway.

    I think what we came up with was the optimal solution. It was discussed multiple times.

    • Not all border-styles are equal. I think it's fine to ignore inset, outset, groove, ridge since they’re effectively legacy. But dashed, dotted, double make perfect sense.

    See above. UAs can render these and it would be spec compliant.

    Additionally, interactions with other planned features either in the same spec or resolved to be added to it are underspecified or not specified at all, such as:

    Yea we should define how these work with border-shape. Those were specified later and haven't shipped anywhere. Let's discuss each of these in isolation?

    I know that the general problem of variable stroke width is considered hard, but do we need to solve the general problem? What if we introduce constraints about the type of shape that can be used? E.g. no self-intersection, max curvature bound, no cusps etc. We could even start strict and relax them over time with no API changes.

    Alternatively (and probably more realistically), can we drop the relevant side rule and treat it as an error (at ??? time) if the border properties are not compatible? Then we can define reasonable interactions in the future without compat getting in the way.

    I am not a big fan of error conditions. If this comes up as a problem in practice we can find a solution.

    To sum up:
    A. border-style rendering is not specified, but that's regardless of border-shape
    B. the relevant side solution feels not great and might interfere with something in the future but it's unclear what
    C. interactions with newer unshipped features is unspecified

    I am suggesting that
    A is a tangential issue about border-style in general;
    B needs a bit more substance to be reasoned about;
    C can be addressed in the context of these new features and is likely solvable.

  5. astearns commented on Oct 20, 2026

    @astearns
    Member

    Taking the agenda tag off in favor of more back and forth here first

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

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions