In browsers that support HTML5, this code draws a diagonal line:
<!DOCTYPE html><html><body><script>
var canvas = document.createElement('canvas');
canvas.width = 100;
canvas.height = 100;
var ctx = canvas.getContext('2d');
ctx.strokeStyle = 'black';
ctx.beginPath();
ctx.moveTo(0, 0);
ctx.lineTo(100, 100);
ctx.lineWidth = 1;
ctx.stroke();
document.body.appendChild(canvas);
</script></body></html>
However, the rendering looks drastically different in Safari:
(Chrome 49.0, Firefox 45.0, Safari 9.0 from left to right.)
I.e., in Safari, the line looks about twice as thick as the others.
Can I do anything to make the line look identical in all three browsers?
The difference is caused by the different ways that browsers anti-alias your line.
You can't over-ride or turn off anti-aliasing on the canvas element so you're stuck with the different line renderings across browsers.
The only sure workaround is to draw your own line pixel-by-pixel. You can use Bresenham's line algorithm to create your line.
Here's example code and a Demo: