I am trying to center a div in a window with padding 10px in html. Whenever I add the padding to the body, the div gets pushed out of the window and scrollbars appear.
HTML Code
<!DOCTYPE html>
<html>
<head>
<title>Test</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<div id="div"></div>
-->
</body>
</html>
CSS Code
html {
margin:0px;
height:100%;
width:100%;
}
body {
margin:0px;
height:100%;
width:100%;
padding:10px;
background-color:#23272A;
}
#div {
height: 100%;
width: 100%;
background-color:red;
}
The div is shown in red in the photos below. It is not centered within the window and there are scrollbars that appear when scrolling. The div extends outside the window.
All help is greatly appreciated!