«
Law of Closure
Contents
Introduction
It wasn’t so long ago that I would think why bother with a closing
I
don’t do that anymore. I used to omit most of the attribute quotes too, which I miss and
it sure keeps file sizes down. But I don’t worry about that too much now that I have tools
like mod_gzip. If you’re not using it you should give it a try. My results are showing
that outgoing XHTML is reduced by around 70% (which saves you on bandwidth costs) and
the pages are rendered much faster on the client-side.
</html> tag?
it’s just HTML after all, and the browser doesn’t care.
But this mindset originated with the lazy style of markup inherent in older versions of HTML. And
also from programming in languages like Perl where: falling off the end of your program is just
a normal way to exit
(Larry Wall, Programming Perl, 3rd Edition, page 3 — see
the about page for the cited source). In other words you’re not required to call exit()
to end your script, the interpreter assumes that’s what you want to do when the source
code ends. PHP is the same way, the only time I ever terminate a script using exit() is in the case of
an error condition when it’s necessary to end execution of the program prematurely.
XHTML is an XML application language folks, end tags are required.
I've adjusted my style of writing markup to (accurately) think of tags as markers for
blocks of related statements. PHP, Perl, Javascript and
C (et al.)
use the same syntax for this, an opening and closing brace character:
{ ... }
Here are examples of each that are so similar it’s almost frightening:
The fix for the first example is as simple as closing the paragraph with a </p>
tag, the second is equally trivial: close the if() block with a ‘}’.
The XHTML returns: My content...
The PHP returns: And the truth shall be known.
I've heard comments from some developers stating they find these XML error messages ugly
or bothersome. Excuse me? The first thing any programmer checks is to make sure their code at the
very least parses correctly (is syntactically valid). Raise your hand if you’ve ever
spent hours wondering why your page doesn’t render correctly because you forgot to
close some tag and the BROWSER NEVER COMPLAINED. I rest my case.
The footer() Function
In the <body> Element lab I eluded to this mystery fourth function in my body.php
library module. There’s nothing mysterious about it at all, here’s an
abridged version:
close the #content </div>display the #footerand #footbarclose the #canvas </div>close the </body> elementclose the </html> element
And there’s your closure. Let’s have a final look at our minimal XHTML document framework:
Hello World?
I don’t think so. I also searched this site for the terms foo
and bar
and found nothing. So I guess you won’t find any such metasyntactic nonsense around here.
I did find a few footer
s and even a footbar
though (see above). What you
can find is a complete sample document on the Next page. It should demonstrate pretty much
everything I've discussed in this series in one neat little package.
Additional Resources
Questions? Comments? Hate my guts? You can Contact Me via email, or post a message to the Discussion Forum.




























































































