Title: Tech Times
Email not displaying correctly? View it in your browser.

Issue 208: September 23, 2008  Tips, Tricks, News and Reviews for Web Coders

Introduction

Andrew TetlawWeb Directions ahoy!

SitePoint is once again sending a delegation of worthy representatives to Web Directions South 2008. And this year it's my turn! If you are attending make sure to come and say hi. It'd be nice to put some faces to the nebulous cloud that is the Tech Times readership.

The lineup of speakers at Web Directions South this year is exciting. Matt Magain, sitepoint.com's Managing Editor, has blogged about all the SitePoint authors, bloggers, and staff who are presenting this year. I'm especially excited about seeing the legend himself: Douglas Crockford.

In this issue Kevin takes a look at HTML and revists what is required to construct a complete HTML document.

Top

What is Fanatical Support®?

The world's hosting leader, Rackspace Hosting, is the expert when it comes to delivering hosting solutions.

It all starts with Fanatical Support®, the commitment to delivering an unequaled customer experience by supporting the technology and the customer 24x7x365.

No call centers or automated phone systems, every Rackspace customer has a dedicated support team managing their account and teams of experts managing the infrastructure, network and hosted solutions for them. And that means the customer can focus on their business - and nothing else.

Click to learn more about Rackspace Hosting.

Summary

by Kevin Yank

I am often surprised by just how many professionally-designed sites are delivered in the form of incomplete HTML documents. To be fair, however, the amount of code required for even an empty HTML document has grown significantly over the years.

One upon a time, an HTML document only had to contain a <!DOCTYPE> declaration and a <title> tag. >From the HTML 3.2 recommendation:

In practice, the HTML, HEAD and BODY start and end tags can be omitted from the markup […]

Every HTML 3.2 document must also include the descriptive title element. A minimal HTML 3.2 document thus looks like:

  <!DOCTYPE HTML PUBLIC
      "-//W3C//DTD HTML 3.2 Final//EN">
  <TITLE>A study of population
    dynamics</TITLE>

At the time HTML 3.2 was the recommended spec, very few web designers bothered with a <!DOCTYPE>, or with valid code at all, so in practice an HTML document could be any text file containing any combination of text and HTML tags.

These days, the needs of accessibility, search engine optimization, document consistency for _javascript_ manipulation, and support for international characters all combine to require more of our HTML. The minimal HTML document has gotten a lot bigger.

Here’s the very minimum that an HTML 4 document should contain, assuming it has CSS and _javascript_ linked to it:

<!DOCTYPE html PUBLIC
    "-//W3C//DTD HTML 4.01//EN"
    "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
  <head>
    <meta http-equiv="content-type"
        content="text/html; charset=utf-8">
    <title>title</title>
    <link rel="stylesheet" type="text/css"
        href=""
    <script type="text/_javascript_"
        src=""
  </head>
  <body>
		
  </body>
</html>

If you want to be able to process your document as XML, then this minimal XHTML 1 document should be your starting point instead:

<!DOCTYPE html PUBLIC
    "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/
xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      lang="en" xml:lang="en">
  <head>
    <meta http-equiv="content-type"
        content="text/html; charset=utf-8"/>
    <title>title</title>
    <link rel="stylesheet" type="text/css"
        href=""
    <script type="text/_javascript_"
        src=""
  </head>
  <body>
		
  </body>
</html>

Read on below for a description of each line of these minimal documents.

Top

Tech Alert :: Geeks love WebHostingBuzz!

Maintaining a website can be both fun and sometimes frustrating especially if the web host does not catch up to your needs. The owners behind WebHostingBuzz have experienced it all.

We have been there and done it. We know what YOU want when it comes to running a script oriented website. We know what YOU want when it comes to value for your web hosting dollars. We host over 150,000 domains across the globe. Surely we can host yours!

Host unlimited websites under one account. Get a free domain name for life, tons of web space and transfer for only $40 per year.

The Breakdown

Every (X)HTML document should start with a <!DOCTYPE> declaration that tells the browser what version of (X)HTML the document is written in. In practical terms, this tells browsers like Internet Explorer and Firefox to use their most standards-compliant (and therefore cross-browser-compatible) rendering mode. The exact form of the <!DOCTYPE> declaration depends on whether your document is HTML 4 (fine for most purposes) or XHTML 1 (enables the page to be processed as XML):

<!DOCTYPE html PUBLIC
    "-//W3C//DTD HTML 4.01//EN"
    "http://www.w3.org/TR/html4/strict.dtd">
<!DOCTYPE html PUBLIC
    "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/
xhtml1-strict.dtd">

Next, we mark the start of the document with the opening <html> tag. This tag should should specify the primary language for the document’s content, with the lang attribute:

<html lang="en">

In an XHTML document, you should also specify the document’s default XML namespace (using the xmlns attribute) and re-specify the language using XML’s standard xml:lang attribute:

<html
xmlns="http://www.w3.org/1999/xhtml"
    lang="en" xml:lang="en">

Next comes the <head> tag, which starts the document header:

  <head>

The first thing in the header should be a <meta> tag that specifies the character encoding of the page. Usually, the character encoding is declared by the web server that sends the page to the browser, but many servers are not configured to send this information, and specifying it here ensures the document is displayed correctly even when it is loaded directly from disk, without consulting a server:

    <meta http-equiv="content-type"
        content="text/html; charset=utf-8">

In an XHTML document, <meta> tags should end with a slash to indicate they are empty:

    <meta http-equiv="content-type"
        content="text/html; charset=utf-8"/>

With the encoding established, we can safely write the first piece of actual content in the page—the page title:

    <title>title</title>

If you want to link a CSS file to the page to control its appearance (which you usually will), a <link> tag at this point will do the trick:

    <link rel="stylesheet"
type="text/css"
        href="">

Again, the XHTML version of this tag needs a trailing slash to indicate it is empty:

    <link rel="stylesheet"
type="text/css"
        href="">

If you want to link a _javascript_ script to the page, and the script is designed to be invoked from the header, insert a <script> tag at this point. Whether the document is HTML or XHTML, you should include a full </script> closing tag for backwards compatibility:

    <script type="text/_javascript_"
        src="">

That just about does it. You can end the header, then start the body of the page with a body tag. The content of the page is up to you, but since we’re talking about a minimal document, there need not be any body content at all:

  </head>
  <body>
		
  </body>
</html>

So, how does your most recent work hold up? Have you included all the elements discussed above? Common omissions like the lang attribute and the content-type <meta> tag may seem unnecessary, but they really put that final layer of polish that ensure your site holds up with the best on the Web.

I’d love to hear your thoughts on the basic HTML elements discussed above, or any other elements you absolutely always include in your pages. Leave a comment and let me know!

kev Web Tech Blog: Technically Speaking
by Kevin Yank

A Minimal HTML Document

Top

No advertisement selected.

See you next week for another issue of the Tech Times!

Andrew Tetlaw
[EMAIL PROTECTED]
SitePoint Technical Editor

Top




Latest Release

The Ultimate HTML Reference

Book

Tell me more..

Free Book Samples

Simply _javascript_
Simply Rails 2
Build Your Own Database Driven Website Using PHP & MySQL, 3rd Ed.
The PHP Anthology, 2nd Ed.

New Technical Articles

Jina Bolton on Creating Sexy Stylesheets

Matthew MagainJina Bolton is a designer and artist, working and residing in Silicon Valley. In this candid interview, she reveals where she finds inspiration for beautiful design, why she is fascinated by sushi and robots, and what makes a style sheet “sexy.”

Full Story...

 Techy Forum Threads

 More Techy Blog Entries

Selling Web Design Services

Why You Should Attend Two Conferences a Year

News & Trends

Facebook About to Make Lexicon Way More Useful
What Makes the Cloud the Cloud
1 comment

Help Your Friends Out

People you care about can benefit from the wealth of information on new and maturing technologies available on the Internet. Help them learn how to do it by forwarding them this issue of the Tech Times!

Send this to a friend
You are subscribed as : [EMAIL PROTECTED]

Unsubscribe [EMAIL PROTECTED] from this list.

Manage your subscriptions.

View the newsletter archives.

Mailing Address:
48 Cambridge St, Collingwood, VIC, 3066 AU
Phone: +61 3 9090 8200
© Copyright 2008 SitePoint. All rights reserved.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "MIS.Suresh" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/missuresh?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to