Recommendation: Keep files well-formed
Don't do this: Breaking a page in half
This technique is not recommended. The first include file contains the top "half" of the page; the content follows; the
second include file contains the bottom "half" of the page. In this technique, the html
,body
, and perhaps other elements are started in the "top half" and their end tags are in "bottom half."
The page delivered to the browser does validate, but the individual parts on the server are not well-formed, which can
cause some confusion when editing a file.
<?php include("header-tophalf.html"); ?>
Lorem ipsum dolor sit amet, consectetuer adipiscing ...
<?php include("footer-bottomhalf.html"); ?>
Keeping things well-formed
<!DOCTYPE html>
<html>
<head>
<title>Lecture Notes</title>
<link rel="stylesheet" href="styles/site.css" />
</head>
<body>
<header>
<?php include("inc/header.php") ?>
</header>
<nav>
<?php include("inc/nav.php") ?>
</nav>
<main>
Lorem ipsum dolor sit amet, consectetuer adipiscing ...
</main>
</body>
</html>