Noobie issue or something else?

Hey guys, I really need some help here understanding why this works this way.

This is my code, it works just fine this way and when I take out the script tags and put everything on codepen correctly it works, but it will not work in an outside script I link to my HTML document. What gives? I keep getting this error. This was an intro exercise to the dom with a local Bootcamp I am in and my TA and I were at a loss.

Any explanation or help is greatly appreciated this really has me hung up.

Uncaught TypeError: can’t access property “style”, document.body is null

<!DOCTYPE html>
<html lang="en">

    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <!-- <link rel="stylesheet" href="./style.css"> -->
    <!-- <script src="./script.js"></script> -->

    <p id="p2">Hello World!</p>
        <li>Nickname: <span id="nickname"></span>
        <li>Favorites: <span id="favorites"></span>
        <li>Hometown: <span id="hometown"></span>

    <script> = "Arial, sans-serif";


It’s because script is trying to run before the body is created, therefore document.body is null.
Put your <script></script> tag before </body>