One corner, two border radii
Kevin just put up a tip o the week article on 2 value border radii: https://html-css-tip-of-the-week.netlify.app/tip/mutliple-corner-radii/
One of the examples says that you can use slashes in the individual radius long-hands. It seems like this should work but it comes back as invalid for me in devtools. Am I missing something?
https://codepen.io/jsnkuhn/pen/jEWbeMv?editors=1100
14 Replies
You don't add the slash when defining them like that.
ah, you already know that from your codepen (just opened it)
I suspect that @Kevin Powell has made a mistake in that article š¤
yeah, i'm not sure I understand why it couldn't be made to work though? I can't think of a reason why the working group would have specifically said "no you can't do it that way." Because it seems like a reasonable thing to expect to work.
oops, yup, going to fix that
also, yeah it's interesting that for the shorthand, you use the
/ but you don't for the shorthand... honestly, the shorthand is a mess imo.
The values for each corner should be together somehow.yeah seems like the most obvious alternative to the shorthand would be width height pairs like with background-size.
So instead of:
we'd have:
yeah, that would have been a lot better.
so... while I was going back and forth with the WG about
corner-shape i brought up the idea of a corner-size property to pair with corner-shape so that we wouldn't have a forced round fallback like we have with border-radius. At the time the answer was that having 2 properties that were the same excepts for a different default value wasn't worth it. I wonder if this change would be enough to make it more worth while?My only thought is this is a pretty niche use case... though I do wonder if having the different radii becomes more useful with corner-shape
for the default
round corner-shape yeah it's pretty niche but for bevel in particular the multi value thing is likely to get used a lot moreso this is worth a try the worst they can say is "no":
[css-backgrounds] allow optional forward slash in border-*-radius long hands
https://github.com/w3c/csswg-drafts/issues/12861
GitHub
[css-backgrounds] allow optional forward slash in
border-*-radius...The border-radius shorthand uses a slash to separate corner widths and heights: border-radius: 2em 1em 4em / 0.5em 3em; However the slash is not used in the individual border-*-radius long hands. I...
Has the article been fixed ? Speaking of confusing this rxqmple from mdn is melting my brain šµāš«
yep the article is fixed. and yeah the css 1-4 value shorthand thing is probably why the slash syntax was chosen over width-height pairs. Can be much less to write: https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_cascade/Shorthand_properties#ordering_properties (don't know why we can't link directly to the "corners of a box" heading)
and yeah the css 1-4 value shorthand thing is probably why the slash syntax was chosenI'd have much prefered 𤷠but also, commas aren't part of the regular spec, right? so maybe that played into it as well. And
border-radius: 4px / 10px 10px 10px 20px / 50px or something would be confusing.I guess it's situational. i can definitely see times when the current slash syntax short hand would be superior to width height pairs. Something like:
instead of having to write:
although you could argue that while the width high pairs are obviously longer it's probably clearer what's going on. The
background shorthand has the same issues. You really have to put some time in to both to understand what's going on.Follow up time. The working group discussed the issue I opened as a result of this thread at TPAC 2025 and resolved to add the optional slash to the spec. https://github.com/w3c/csswg-drafts/issues/12861#issuecomment-3525806102
RESOLVED: Allow forward slash in these properties
GitHub
[css-backgrounds] allow optional forward slash in
border-*-radius...The border-radius shorthand uses a slash to separate corner widths and heights: border-radius: 2em 1em 4em / 0.5em 3em; However the slash is not used in the individual border-*-radius long hands. I...