"Problem"
Here is a diagram, fom w3c , showing what happens when a float overlaps the boundaries of elements in a normal stream.

This behavior of floating elements causes the height of the parent element to do what most developers consider unintuitive.
But, given that it is documented in w3c, this is intentional: this is not a mistake.
The solution you found
So here is an interesting rule in your CSS:
header:after { clear:both; content:"."; display:block; height:0; visibility:hidden; }
This rule targets the <header> element, but also uses :after pseudo-element . As a result, it looks like an imaginary element after the <header> that you are targeting this CSS rule:
<!DOCTYPE html> <html> <head> <link rel="stylesheet" href="css/template.css" type="text/css" > <title>Teaching myself CSS, HTML. I want help understanding this bug.</title> </head> <body> <section class="content"> <header id="contact"> <div id="name">Name</div> <div id="address"> <div>Home Address</div> </div> <div id="contact-details"> <div><strong>Phone Number:</strong>5555 </div> </div> </header> This text should be under everything else. </section> </body> </html>
This imaginary header:after "element" that is added after the <header> has the clear:both CSS property:
header:after { clear:both; content:"."; display:block; height:0; visibility:hidden; }
So what does clear do? According to w3c ...
This property indicates which sides of the element (s) of the element cannot be adjacent to an earlier floating field.
Less reliable, but sometimes clearer, w3schools describes clear as ...
The clear property indicates which sides of the element, where other floating elements are not allowed.
Since the header:after element has the CSS property clear:both , any floating elements on the left or right side, such as red and green fields, will appear at the bottom (after).
Now, this resettemp.css file seems to target almost every element that you can imagine with the same trick - a kind of carpet bomb approach to solving the float - overflow problem. The best idea is to learn CSS: P
You can also use header { overflow:hidden; } header { overflow:hidden; } - depending on your needs.