Is it possible to have a border that is thinner than 1px and works in IE6+ and is not an image and renders properly visually?
Thank you.
Is it possible to have a border that is thinner than 1px and works in IE6+ and is not an image and renders properly visually?
Thank you.
No. You can't show a size smaller than one pixel because pixels are the basic unit of the monitor. And anyway, no browser I know of allows you to specify sub-pixel widths. They just get rounded up to 1px or down to 0px.
To render native 1px borders on high DPI/@2x/retina displays, there are a couple of tricks.
On Firefox and Safari (macOS and iOS), use a
0.5px
border:On Chrome, use a box-shadow with a 0.5px spread:
Use JS to add a class to the HTML element to only target @2x+ displays.
For @1x displays, use a slightly lighter color 1px border.
I don't know about IE8-10 (IE6-7 definitily no go) , but in Chrome and FF I get the thinnest border with box-shadow. Works best to get a 1px <hr> instead of the autorendered 2px, but can be used on a border as well.
The thin border on the HR is more prominent in FF than Chrome, but also Chrome renders 2px.
http://jsfiddle.net/GijsjanB/3G28N/
you can transform the line like that:
or, if the line is vertical
Although this isn't (currently) possible in any version of IE or Edge, on the latest versions of Firefox and Chrome you can now use border width values less than 1px.
This outputs the following on a UHD screen:
I think you could define the width of a border using units like
em
which would come out to less than 1px, and it would be valid. However, like Will Martin said, for display purposes it would just round it up or down to a whole pixel.