Open emilio opened 2 years ago
The CSS Working Group just discussed [css-ui] Outline rects of an inline
.
Came across this while experimenting with nice styling for multi-selectable cells in a sudoku grid. I made a demo here: https://observablehq.com/@supermikal/css-outline-rects-demo
The styles are a bit messy due to several iterations of trial and error, so it might not be a minimal repro but it's_something.jpg
Screenshot from Chrome for Android 98.0.4758.101:
Firefox for Android 97.2.0 (Build #2015863827), fc8bbf84c+ :
As a web developer, the behavior of Blink is surprising to me here. When I draw outside of the border box for some reason, I expect outline to draw around the border box and not around the stuff I drew outside of that box. My (potentially incorrect) understanding of outline is that it is similar to a border, but it doesn't consume space (thus making it a good tool for hover/focus as it won't trigger reflow like adding a border will).
The situation that caused me to spend a couple hours debugging was something like this:
<style>
my-element {
outline: auto;
outline-color: red;
border: 1px solid blue;
display: inline-flex;
flex-direction: column;
}
my-element::after {
height: 0;
content: 'words';
visibility: hidden;
}
</style>
<my-element>More Text</my-element>
In this example note that the ::after
is invisible to both the user and the layout engine, yet the outline encapsulates it on Chromium browsers.
A potential middle ground that would address this specific issue would be to treat visibility: hidden
the same as overflow: hidden
, which causes the outline to ignore the overflow. Even with this change, I still feel like this behavior would be surprising to developers, but not quite as surprising as having outlines of empty boxes.
You may find some screenshots for this issue in MediaWiki.
Context:
text-indent: -9999px
or so to hide text on some controls.So given that browsers are agreeing now to draw the outline around the border area, not including descendants, except for this Blink special-case, can we spec outline rects finally?
I think I'd prefer agreeing on the Gecko + WebKit behavior, since it's consistent with borders and outlines on all other boxes.