This does not look like what I intended.
<!-- test-2.html -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset = "UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Space around left-box</title>
<style>
main {
max-width: 5.6in;
border: 2px solid blue;
margin-left: auto;
margin-right: auto;
padding: 1rem;
}
h1, h2 {
padding: 0;
margin: 0;
}
p {
margin-top: 0;
margin-bottom: 0
;
}
#left-box {
float: left;
min-width: fit-content;
max-width: 200px;
background: #eee;
font-size: 0.8em;
padding: .5rem;
margin-left: 0;
margin-right: 1rem;
border: 1px solid #aaa;
display: grid;
}
#left-box ul {
list-style: none;
margin-top: 0;
margin-left: 0;
padding-left: 0;
}
.text-block {
display: block;
border: 1px solid red;
margin: 0.5% 3% 0 10%;
}
</style>
</head>
<body>
<main>
<h1>How can I get the same indentation around a "float; left"? </h1>
<p>The <div id="left-box"> floats to the left. There is a 1rem padding for the content of <main>. </p>
<div id="left-box">
<ul>
<li><a href="#sec1">Section 1</a></li> <li><a href="#sec2">Section 2</a></li>
<li><a href="#sec3">Section 3</a></li>
</ul>
</div>
<section id="sec1">
<h2>Section 1 <h2> align to the left.</h2>
<div class="text-block">
<p>The text in this section is inside <code>.text-block {display: block; margin: 0.5% 3% 0 10%; border: 1px solid red;}</code>. I want this to be indented like that seen in section 2 below. However it buts up against the left box.</p>
<p>Ideally, the first letter of the paragraph would align below the "o" of "Section" and other lines would start there until they could go below the "left-box."</p>
</div>
</section>
<section id="sec2">
<h2>Section 2 <h2> aligns in the left left.</h2>
<div class="text-block">
<p>Notice the exaggerated indentation of this paragraph. It is inside the same class="text-block" as the paragraph in Section 1 above. </p>
</div>
</section>
<section id="sec3">
<h2>Section 3 <h2> also aligns in the left left.</h2>
<div class="text-block">
<p>Thank you for taking the time to read this and for teaching us.</p>
</div>
</section>
</main>
</body>
</html>