-
200719 Jun
Posted in CSS3 Preview, Declarations, Modules, W3C
With the release of Safari 3, there are now two browsers with (browser-specific) implementations of
border-radius; unfortunately, the two implementations are different. The problem is that there is an unresolved ambiguity in the CSS 3 working draft.The draft proposes four declarations, which describe the four corners of a block:
border-top-left-radius border-top-right-radius border-bottom-right-radius border-bottom-left-radius
Each of them should accept two values, which
define the radii of a quarter ellipse that defines the shape of the corner
; this allows for irregular curves (take a look at the diagram in the draft if you need clarification, or see this example of a box withborder-radius: 5px 20px, horribly rendered in Safari for Windows).Safari, with the prefix
-webkit-, accepts these. Mozilla, with the prefix-moz-(and differing declarations), accepts only a single value and, therefore, only regular curves.At first glance, it would appear that Mozilla are in the wrong; however, their implementation is due to the ambiguity I mentioned earlier.
This ambiguity comes about in the
border-radiusshorthand property; if you enter a double value in this you’d expect to apply the irregular curves to all four corners:border-radius: 5px 10px;
If you wanted to have four different irregular curves on the box, you’d have to provide eight values to the declaration:
border-radius: 5px 20px 10px 5px 10px 20px 20px 5px;
But what if you wanted to have two corners with one value, and two corners with a different value?
border-radius: 5px 10px 10px 20px;
The problem is that this could be confused for four corners with regular curves. In order to get around this, you’d still have to provide eight values:
border-radius: 5px 5px 10px 10px 10px 10px 20px 20px;
In fact, from the brief testing I’ve done (and I can’t find any documentation), it seems you can’t do any of that; unless I’m missing something, the shorthand declaration in Safari accepts only 1 or 2 values, to provide either regular or irregular curves which are applied to all four corners. If you want different irregular corners, you have to supply values to all four declarations:
border-top-left-radius: 5px 20px; border-top-right-radius: 10px 5px; border-bottom-right-radius: 10px 20px; border-bottom-left-radius: 20px 5px;
Mozilla avoid this by going against the spec and allowing only regular curves; so you can provide 1, 2, 3 or 4 values and it’s all perfectly clear.
This problem is down to interpretation of the draft. I personally think Mozilla’s non-standard solution is better - it’s less flexible, but easier to understand - but can’t blame the Safari team for following the standard in their implementation.
It will be interesting to see which comes out on top; in the meantime, if you want to use
border-radiusin your code the only way to get them to appear the same on both browsers is with a single value for four regular corners:-moz-border-radius: 10px; -webkit-border-radius: 10px;
You can skip to the end and leave a response.
-
Comments
-
01.
Good piece Peter :) have you, by any chance, tested how Konqueror behaves with this as well?
-
02.
I’ve read that Konqueror supports -khtml-border-radius, but can’t find any official confirmation, and can’t get it to work.
-
03.
leksó says:Comment » June 19th, 2007 at 11:44 am
Could you attach a screenshot of such a irregular curve ?
-
04.
I’ve added an example of -webkit-border-radius: 5px 20px to the post; I have to say, the rendering is horrible. I’m not sure if that’s because it’s Safari for Windows, perhaps someone with an OS X version could try?
-
05.
Maybe it’s an idea to add a character like / to the value, like in
font. So what’s before the character is the X radius, and after the character is the Y radius. If the character isn’t used, the value will be for both the X and Y radius. So now you can have something like this:border-radius: 5px/20px 10px/5px 10px/20px 20px/5px; -
06.
Good idea, Arjan; a slash or a comma, like font-family uses:
border-radius: 5px 20px, 20px, 10px 20px, 20px;
I wonder if irregular curves are the way to go, however; the current implementation in Safari is horrible, whereas regular curves come out looking really nice.
-
07.
Just to clarify, you *can* get identical rendering on WebKit and Gecko with a different radius on each corner. You just have to use the individual properties like
-webkit-border-top-left-radiusand-moz-border-radius-topleft. I’ve been using that technique to create tabs with rounded corners since I started playing with WebKit nightlies a few months ago. -
08.
And after messing around with that irregular-corner code, I think the reason it looks bad is that the smaller radius of 5px is the same width as the border. If you use a narrower border, like 1px or 2px, or if you use the 5px border with 20px and 40px for the radius, it looks fine.
-
09.
CSS3 gathering speed……
over at CSS3, Paul Gasston has been diligently track the adoption and implementation of all things CSS3. His latest post concerning rounding corners highlights the frustration……
-
10.
Diferencias entre el uso de border-radius en safari 3 y mozilla…
Un artículo acerca del diferente tratamiento que se ha dado a la propiedad border-radius en Safari 3 y Mozilla. Por lo visto viene de una mala intepretación de la especificación…
-
11.
[...] Originally posted on CSS3.info. [...]
-
12.
Geoffrey says:Comment » June 24th, 2007 at 4:10 am
Safari on Mac OS X renders exactly the same. But I do agree with Kelson, if the border size isn’t the same as the minor size, it looks much better.
-
13.
Hmm, confusing. Though, I don’t see a problem with forcing the shorthand declaration to only take 4 values (one for each corner, regular only) whilst allowing non-regular corners with the individual declarations; it wouldn’t be the first shorthand property to not allow every aspect to be specified at once.
How can you say that screenshot from Safari is horribly rendered? It’s not as good as it should be, sure, but Firefox makes border-radius look like ass… It’s much better to avoid it at the moment, if you’re targetting FF, as it looks really pixellated and awful. See my work in progress (link below) and compare the beautiful rendering in Safari to FF’s piss-poor attempt.
I say stick with images till this stuff gets sorted out.
-
14.
I think the inside of that border IS rendered horribly, but I’m sure if you matched the internal colour to the border it would look great.
Firefox 3’s corner rendering is better than FF2’s, judging by the preview I’ve been playing with.
It probably is safer to stick to images until this gets sorted out, I agree; although, it would be better if we could have multiple background images!
-
15.
eisa01 says:Comment » July 3rd, 2007 at 11:15 pm
There’s another difference between the two that you haven’t brought up. If you apply a background picture to e.g. add some depth to what you’re making, Mozilla won’t clip it, so you’ll end up with square corners. Safari does the logical thing and applies the border radius to the background image as well.
It’s acknowledged in their bug database, but if it’s time to fix it for FF3 is another matter.
-
16.
Peter: I believe you’re right on that one, the outside is better than the inside, but it’s still not perfect. I don’t test against/use FF3 at all, so that’s cool if it is indeed better.
I suppose this kind of thing is the peril of playing with pre-spec stuff, but it does rather take the p**s that in 2007 we still can’t make a box with pretty rounded corners programmatically.
Meanwhile, Safari has apparently supported multiple background images since the dawn of time (well, for ages, anyway) - although I only found out a few weeks ago.
-
17.
you *can* get identical rendering on WebKit and Gecko with a different radius on each corner. You just have to use the individual properties like -webkit-border-top-left-radius and -moz-border-radius-topleft.
Kelson - what do you do for Opera ?
-
18.
@Anjanesh: You don’t. Opera has no border-radius implementation at the moment.
-
19.
-
20.
Interesting article and certainly shows that CSS3 could become unnecessarily complicated and I’d tend to agree with Mozilla’s interpretation of the spec.
There’d also be the option of using border-image once this has been more widely adopted for any complicated irregular borders.
-
21.
[...] border-radius: Safari vs Mozilla July 17th, 2007 — mozienigma border-radius: Safari vs Mozilla [...]
-
22.
For what it’s worth, Mozilla has implemented -moz-border-radius since before it was in any css3 draft (see cvs history; note revisions 3.59 and 3.98). The first W3C draft I could find with border-radius was much later. I don’t recall if the differences between them are simply the editor’s preference or whether the working group has actually discussed which is preferable.
-
23.
I’d just like to note that thanks to this discussion the CSSWG has adopted Mozilla’s shorthand syntax. :)
-
24.
[...] our discussion of the inherent ambiguity in the border-radius declaration, it has been decided that the simpler syntax used by Mozilla will used for the shorthand; that is, [...]
-
25.
Αυτόματη προσθήκη -webkit-border-radius όπου έχετε -moz-border-radius « My little web design & development tips says:Comment » June 20th, 2008 at 8:22 am
[...] κάποιο τρόπο να τα αντικαθιστά και τα 2 με ένα query λόγω ασυμβατότητας μεταξύ των implementations του κάθε browser. Για να ξεπεραστεί αυτή η ασυμβατότητα το πρώτο [...]
-
26.
CSS 3. border-radius | webmasters, recursos webmasters, recursos gratuitos, scripts, web says:Comment » July 9th, 2008 at 11:33 pm
[...] Podeis obtener más información sobre la propiedad border-radius, y como la interpretan los navegadores que la soportan en este artículo: border-radius. Apple vs Mozilla. [...]
-
27.
-
28.
[...] in the same way that you specify multiple border thicknesses, margins or paddings. As describe by Peter Gasson on CSS3.info, in the Mozilla specification they allow only regularly rounded corners and thus you can specify a [...]
-
29.
It would also seem that Mozilla isn’t following the Border radius naming guidelines.
I cannot get
-moz-border-radius-bottom-left: 10px;
-moz-border-radius-bottom-right: 10px;to work, but I can get this
-moz-border-radius-bottomleft: 10px;
-moz-border-radius-bottomright: 10px;to work
-
30.
Lensco.be | Blog | Border-radius: a tale of two browsers says:Comment » September 6th, 2008 at 3:08 pm
[...] topic has been described in detail on the css3.info website. It boils down to the fact that although the Firefox shorthand syntax of border-radius looks [...]
-
31.
applying background-clip (border) to border-radius elements will make it more smooth.
-
01.
TAG CLOUD
acid3
advanced layout
background
border
Browsers
color
css
CSS3.info
CSS WG
csswg
developer tools
disabled
dom
enabled
feedback
firefox
firefox 3.1
fonts
generated content
grid positioning
hixie
HSLA
HTML5
ie6
ie7
ie8
jina bolton
media player
Opera
Opera Dragonfly
presentations
RGBA
safari
selectors
slides
SVG
text rendering
UI
W3C
wasp
Web Fonts
webkit
windows







Leave a Comment