Join Bill Weinman for an in-depth discussion in this video Creating and using templates, part of XHTML and HTML Essential Training.
- View Offline
So now that we've covered this structure of the XHTML document, and you know what all this stuff is that's required in every document, I know you're not going to want to type it every time and neither am I. I'm a big fan of lazy. So what I do is I keep around templates. Now as a starting point, I have this transitional-xhtml-template, which I actually use every time I'm doing to build a new document from scratch, and I start with this. It's got all the stuff that's required. It's got a placeholder for my document title, has a placeholder for where I start typing in my content.
Once I've designed a site, like for instance this one here. This is a site that we'll be using later on in the course to show how we do layout in a complete site. And this is the template for it. After I've designed the site and I've built the front page, I tear out the content and I create a template that's got just all the elements that are going to be consistent across the website. And down here I've got placeholders. Here's where my main content goes, here's where my sidebar content goes, here's where the title goes, and the rest of it is just constant.
So here's what it looks like in the browser. This is my little transitional template. This is the template for the website that we'll be looking at in more detail later on in the course. And here's the place for the main content. Here's the place for the sidebar content. I don't have type any of this anymore. Like I said, I'm a big fan of lazy. This is something that you can do to make to make it possible to use well structured documents that are correct and that will work well in a variety of browsers, and in a variety of media, and without really anymore effort than you would put into just the designing the things once.
No more effort really than it would be just to use plain old ugly HTML, to be able use well formed XHTML that will work across platforms and well into the future on all kinds of new devices. So use your templates. Become a fan of the lazy.
- Understanding the structure of an HTML or XHTML document
- Creating and using templates
- Controlling white space and line breaks
- Making effective use of tables and frames
- Flowing text around an image
- Formatting tables with CSS
- Creating web pages that work properly across platforms and devices
- Reviewing a case study of a complete web site