Skip to content
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

[css-backgrounds] Clarify how border-width and border-style affect border-image #655

Closed
SelenIT opened this issue Oct 27, 2016 · 4 comments

Comments

@SelenIT
Copy link
Collaborator

SelenIT commented Oct 27, 2016

There is a confusion about how border-width and border-style should affect border-image (and should they). In the example of border-image with nonzero border-image-width combined with either border-width:0 or border-style:none, browsers behave differently. Firefox and IE11 render border-image in all these situations, Edge 14 — only if border-style is not none, iOS 10 Safari — only if border-width is not 0, and Chrome requires both to render it.

It seems to be a popular assumption that border-style should override border-image (e.g. see the note 1 on the caniuse.com page for border-image). However, the current spec clearly says that border-style and its sub-components "set the style of the border, unless there is a border image", implying that border-style shouldn't affect border-image if its own sub-components values allow it to be rendered.

The test suite for this section (especially tests border-image-width-005, border-image-width-006, and border-image-width-007) marks the current behavior of Firefox (i.e. ignoring both border-style:noneand border-width:0 if there is valid border-image with explicit non-zero border-image-width) as correct.

But there seems to be a bit of ambiguity in the spec in relation to border-width. The section for this property has the following remark:

When the used width of the border is 0, we say that the border is absent.

And there is no clarification if it is about just "regular" border or about image border, too. Should we add such clarification?

@tabatkins tabatkins added the css-backgrounds-3 Current Work label Nov 1, 2016
@fantasai
Copy link
Collaborator

Boris Zbarsky raised an issue on the "unless there is a border image" wording earlier, and this sentence has now been rewritten. https://drafts.csswg.org/css-backgrounds-3/#the-border-style

In any case, the computed value of 'border-width' is very explicitly defined to be zero for none and hidden borders. Additionally, the border image section is very explicit that none of the properties therein affect layout. Since by default a border image is only drawn in the border area, by default a border-style of none will make it disappear. However, the border-image-outset and border-image-width values can alter the “border” area into which the border image is drawn, extending it into the padding area (in the case of border-image-widths greater than the border-width) or extending it outside the border edge (in the case of border-image-outset greater than zero).

So, border images override border-style in the sense that a border-style-specified border will not be drawn if a border image is specified. But to the extent that border-style influences the border-width it can affect whether the border image is visible or not.

Please let me know if that's clear or if you think some further explanation is needed (here or in the spec).

@fantasai
Copy link
Collaborator

When the used width of the border is 0, we say that the border is absent.

The only place that uses this terminology, afaict from a grep, is the css-box spec which is unmaintained and outdated. I will remove the sentence.

@SelenIT
Copy link
Collaborator Author

SelenIT commented Sep 22, 2017

@fantasai, thanks for removing the ambiguous phrase!

So is it right that if border-image-width is explicitly set in length units and is greater than zero, then the border image should be rendered even if the used value of border-width is 0 (as expected in the testcases)? So Gecko does it correctly and Blink's behavior is currently a bug?

@fantasai
Copy link
Collaborator

Yes, per spec it should be rendered. I suppose making ''border-style: none'' disable the border image is an interesting interpretation, though.

SelenIT added a commit to SelenIT/caniuse that referenced this issue Dec 30, 2018
Chromium supports border-image-repeat: space since version 56 (according to MDN), so other browsers based on corresponding Chromium versions should do also.

It also may be worth noting that Blink and Edge seem to have "overfixed" the issue from the first note, reading the exception in the old spec too broad and creating another bug ([spec discussion](w3c/csswg-drafts#655), [Chromium bug](https://bugs.chromium.org/p/chromium/issues/detail?id=767352)). Should it be added to the table?
SelenIT added a commit to SelenIT/content-1 that referenced this issue Sep 14, 2021
The specification actually doesn't _require_ `border-style` and/or `border-width` for `border-image` to be rendered (w3c/csswg-drafts#655 (comment)). However, some browsers indeed would not render it without them (although this is technically a bug and is being fixed), so specifying them is a reasonable practical requirement at the moment (and providing fallbacks is a good practice anyway).
rachelandrew pushed a commit to mdn/content that referenced this issue Sep 15, 2021
The specification actually doesn't _require_ `border-style` and/or `border-width` for `border-image` to be rendered (w3c/csswg-drafts#655 (comment)). However, some browsers indeed would not render it without them (although this is technically a bug and is being fixed), so specifying them is a reasonable practical requirement at the moment (and providing fallbacks is a good practice anyway).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants