HTML5 and CSS3 All-in-One For Dummies
Book image
Explore Book Buy On Amazon

Of course, if you have access to PHP, it’s really quite easy to build HTML5 and CSS3 pages dynamically. Take a look at the csInclude.php program to see how this is done:

<!DOCTYPE html>
<html lang = "en-US">
 <head>
 <meta charset = "UTF-8">
 <title>CS PHP Includes</title>
 <link rel = "stylesheet"
   type = "text/css"
   href = "csStd.css" />
 </head>
 <body>
 <div id = "all">
  <!-- This div centers a fixed-width layout →
  <div id = "heading">
  <?php include("head.html"); ?>
  </div><!-- end heading div →
  <div id = "menu">
  <?php include("menu.html"); ?>
  </div> <!-- end menu div →
  <div class = "content">
  <?php include("story1.html"); ?>
  </div> <!-- end content div →
  <div class = "content">
  <?php include("story2.html"); ?>
  </div> <!-- end content div →
  <div id = "footer">
  <?php include("footer.html"); ?>
  </div> <!-- end footer div →
 </div> <!-- end all div →
 </body>
</html>

Using PHP is almost the same as using an SSI and AJAX approach:

  1. Start by building a template.

    The general template for all three styles of page inclusion is the same. There’s no need to change the general design or the CSS.

  2. Create a small PHP segment for each inclusion.

    In this particular situation, it’s easiest to write HTML code for the main site and write a small PHP section for each segment that needs to be included.

  3. Include the HTML file.

    Each PHP snippet does nothing more than include the appropriate HTML.

About This Article

This article is from the book:

About the book author:

Andy Harris taught himself programming because it was fun. Today he teaches computer science, game development, and web programming at the university level; is a technology consultant for the state of Indiana; has helped people with disabilities to form their own web development companies; and works with families who wish to teach computing at home.

This article can be found in the category: