Flex has something to do with that center alignment. All I know is that it doesn't work without it.
I feel like there is probably some small error in your code, so just copy this:
<!DOCTYPE html>
<html>
<head>
<link type="text/css" rel="stylesheet" href="style.css"/>
<title>Placeholder</title>
</head>
<body>
<div id="main1">
<p>Test</p>
</div>
</body>
</html>
body
{
background: lightgray;
font-size: small;
font-family: verdana, arial, helvetica, sans-serif;
margin: 0px;
padding: 0px 100px;
height: 800px;
display: flex;
align-items: flex-start;
flex: 1;
}
#main1
{
width: 200px;
align-self: center;
background-color: white;
padding: 100px;
margin: 0px;
}