spacer
Yehuda Shiran October 26, 1999
Close Your Tags
Tips: October 1999

Yehuda Shiran, Ph.D.
Doc JavaScript

Developer News
Microsoft Shows Off Silverlight 4, IE9 Plans
Metasploit Expands Vulnerability Test Framework
HyperCard Reborn?

HTML is a very flexible language. It never generates errors, and often provides many different ways to accomplish a single task. For example, a list item can be specified as <LI>description or <LI>description</LI>. The only difference is the closing </LI> tag, but it might be your biggest mistake. Let's find out why.

If you don't close these tags, the browser renders your pages just fine. If you do close your tags, it will render your pages even faster. Take a look at the following code segment:

<P>Here is a list of names:
<UL>
<LI>Yehuda
<LI>Yael
<LI>Tomer
<LI>Dikla
<LI>Carmit
<LI>Alon
</UL>

As you can see, the <P> and <LI> items are included without their closing counterparts. When parsing such HTML code, the browser needs to look ahead to find out where the paragraph or list item ends. The following code generates the same output in a more efficient method:

<P>Here is a list of names:</P>
<UL>
<LI>Yehuda</LI>
<LI>Yael</LI>
<LI>Tomer</LI>
<LI>Dikla</LI>
<LI>Carmit</LI>
<LI>Alon</LI>
</UL>


People who read this tip also read these tips:

Look for similar tips by subject:

internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs

webref The latest from WebReference.com Browse >
Rolling Out Your Own HTML Application Version Control · HTML 5: Client-side Storage · Working with Ajax Server Extensions
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Wi-Fi Product Watch, November 2009 · Chip Market Recovering From '08 Collapse · Low-Cost Tools to Kickstart Your New Business