web developers



Concentrating on the credit portion, this bit of POSH code can be enhanced with even greater meaning by overlaying a microformat. For instance, one way to assign classes and pieces of information to the credit information might be:

<div id=”hcard-Robert-M-Cherny” class=”vcard”>
<h3>About the author:</h3>
<h4><a class=”url fn n” href=”http://navigationarts.com”>
<span class=”given-name”>Rob</span>
<span class=”family-name”>Cherny</span></a><br>
<span class=”title”>Lead Developer</span></h4>
<p>
<span class=”org”>NavigationArts, LLC</span><br>
<span class=”adr”>
<span class=”street-address”>
7901 Jones Branch Road</span><br>
<span class=”locality”>McLean</span>,
<span class=”region”>VA</span>,
<span class=”postal-code”>22102</span>
<span class=”country-name”>
United States of America</span><br>
<span class=”tel”>703.584.8920</span>
</span>
</p>
</div>

This example adopts the hCard microformat defined at microformats.org. The classes defined for vcard, given-name, additional-name, family-name, org, adr, and so forth identify key pieces of information. While on the markup-heavy side, it does, in a very granular way, specify the meaning of each element, which is of potentially great use.

In XML, tags give meaning to each field of information. With microformats, valid class and other attribute information can be added to the POSH code to enable understanding of the granular pieces of information.







There are two things wrong with this from a best practices standpoint. Both have to do with the naming of the classes on the <p> elements: rederror and bolduser both convey presentation information that implies what those elements look like. The standard practice is to avoid basing a name on a description of a “physical” or visual characteristic.

A better solution might be:

<style type=”text/css”>
p.errormessage {color: red;}
p.userfield { font-weight: bold; }
</style>
<p class=”errormessage”>Warning: Username not found!</p>
<p class=”userfield”><label for=”username”>Username:</label>
<input type=”text” id=”username” name=”username” /></p>







The remaining step in improving the sample page is to add dynamic elements after the page has loaded. Unless the elements of the document can serve some purpose when scripts are disabled, it may be best to add the elements after the page has loaded.

The W3C DOM includes a whole series of functions for inserting content and markup into a document. These are highly effective; however, for expediency, Microsoft introduced a proprietary DOM extension called innerHTML that inserts snippets of code into a document. As fate would have it, this method is not only faster to code, but performs faster in the browser as well. The benefits were difficult to deny, so every other major browser vendor that supports W3C DOM standards-based code has implemented this feature. That makes it exceptionally safe and convenient to use. Although some purists balk at its use because it is considered nonstandard, for our purposes here it is too convenient not to use.