Can someone please explain the unexpected behavior for margin:0 style in body
Here's my code snippet:
<!DOCTYPE html>
<html>
<head>
<title>SVG Shapes</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
body, html {
padding: 10px;
margin: 0;
}
svg {
width: 100%;
height: 100%;
padding: 15px;
border: 1px solid red;
}
</style>
</head>
<body>
<svg>
<rect width=300 height="100" style="fill:rgb(0, 0, 255); stroke-width:3; stroke:rgb(0,0,0);" />
</svg>
</body>
</html>
What I'm expecting is that the svg will be inside the body(with a padding of 10px on all sides) and there won't be any scroll bar. But what is happening is that top and left padding for body is working fine, but the right padding is not. The right border for svg is sticking with the body(check out the image for clarification).