PHP executed success query echo breaks favicon

On all my pages I am echoing a success alert if the query was successfully executed, similarly if it does not there is an error message also echoed.

I have noticed every time the query has ran, and the echo is performed, it is breaking the favicon (i.e. the favicon icon does not load and the default grey globe is appearing). It also triggers Quriks Mode.

What methods can be utilised to echo deeper into the HTML (after all meta tags, scripts etc…) rather than at the very top of the opening body tag.

The favicon loads fine when laoding the page before any query is executed and after testing it is the echo that is causing this issue.

if($stmt->execute()) {
    
echo '<div class="alert alert-success alert-dismissible fade show notif-alert" role="alert">';
echo '<strong>Success!</strong> Password was changed successfully!';
echo '<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>';
echo '</div>';

} else { 

echo '<div class="alert alert-warning alert-dismissible fade show notif-alert" role="alert">';
echo '<strong>Error!</strong> An error occured, please try again!';
echo '<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>';
echo '</div>';
echo "Error: " . $stmt->error;
    
}

After the echo you can see where the div is being inserted

<body>
<div class="alert alert-success alert-dismissible fade show notif-alert" role="alert"><span><strong>Success!</strong> User information updated successfully!</span><button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button></div>

<meta charset="utf-8">