We separate the code into a main portion which you can change, as well as "preface" and "postscript" portions which are vital to make things work, but not what we're concentrating on for the current example.
In real life, the three bits would all be together in a single HTML file. We just separate them to help illustrate the areas we're particularly interested in at the time.
To the right is a live preview of what that code produces. As you type and change the code, the preview changes.