Home

How to Build the HTML5 Template Framework for Your Site

|
Updated:  
2016-03-26 13:13:10
|
HTML5 and CSS3 All-in-One For Dummies
Explore Book
Buy On Amazon

With a page layout in place, you can finally start writing some HTML5 code. Begin with your standard page layout diagram and create an HTML template to implement the diagram in working code. The HTML template is quite simple because most of the design should happen in the CSS. Keep these guidelines in mind:

  • Remember that the template is simply a framework. The HTML is mainly blank. It's meant to be duplicated and filled in with live data.

  • It has a reference to the style sheet. External CSS is critical for large web projects because many pages refer to the same style sheet. Make a reference to the style sheet, even though it may not actually exist yet.

  • Include all necessary elements. The elements themselves can be blank, but if your page needs a list for a menu, add an empty list. If you need a content div, put it in place.

  • Create a prototype from the template. You'll need sample data in order to test the CSS. Build a prototype page that contains typical data. The amount of data should be typical of the actual site so that you can anticipate formatting problems.

It's very possible that you'll never manually put content in your template. There are several options for automating this process.

The HTML template should be easy to construct because everything you need is in the page template diagram.

image0.jpg

Here's the HTML code for the prototype:

<!DOCTYPE html>
<html lang = "en-US">
 <head>
 <meta charset = "UTF-8">
 <title>CS Standard Template</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">
  <h1>Heading</h1>
  </div><!-- end heading div →
  <div id = "menu">
  menu
  <ul>
   <li><a href = "#">one</a></li>
   <li><a href = "#">two</a></li>
   <li><a href = "#">three</a></li>
  </ul>
  </div> <!-- end menu div →
  <div class = "content">
  <h2 id="tab1" >Content 1</h2>
  One or more of these will contain content
  One or more of these will contain content
  One or more of these will contain content
  One or more of these will contain content
  One or more of these will contain content
  One or more of these will contain content
  One or more of these will contain content
  One or more of these will contain content
  </div> <!-- end content div →
  <div class = "content">
  <h2 id="tab2" >Content 2</h2>
  One or more of these will contain content
  One or more of these will contain content
  One or more of these will contain content
  One or more of these will contain content
  One or more of these will contain content
  One or more of these will contain content
  One or more of these will contain content
  One or more of these will contain content
  </div> <!-- end content div →
  <div id = "footer">
  contact and footer info
  </div> <!-- end footer div →
 </div> <!-- end all div →
 </body>
</html>

People commonly start writing pages at this point, but that's a dangerous idea. Don't use any real data until you're certain of the general HTML structure. You can always change the style later, but if you create 100 pages and then decide that each of them needs another tag, you have to go back and add 100 divs.

About This Article

This article is from the book: 

About the book author:

Andy Harris earned a degree in Special Education from Indiana University/Purdue University–Indianapolis (IUPUI). He taught young adults with severe disabilities for several years. He also taught himself enough computer programming to support his teaching habit with freelance programming.
Those were the exciting days when computers started to have hard drives, and some computers connected to each other with arcane protocols. He taught programming in those days because it was fun.
Eventually, Andy decided to teach computer science full time, and he still teaches at IUPUI. He lectures in the applied computing program and runs the streaming media lab. He also teaches classes in whatever programming language is in demand at the time. He has developed a large number of online video-based courses and international distance education projects.
Andy has written several books on various computing topics and languages including Java, C#, mobile computing, JavaScript, and PHP/MySQL.
Andy welcomes comments and suggestions about his books. He can be reached at [email protected].