Improve Site Performance Increase Site Traffic Monitor Site Uptime Webmaster Resources NetMechanic Home Looking For Help? Partner Programs Privacy Policy Contact Us Press Room
NetMechanic Home LOGIN | HELP | ABOUT US | PRODUCTS | SITE MAP
NetMechanic Menu
Over 52 Million Web Pages Tested!     
 
Story on base tag.
base tag story search bar.
Search for:


Your Email:

I would like to receive my newsletter in:
HTML format
Text format


Tips on managing links.
Volume 8 (2005)
   September
   June
   April
   March
   January

Volume 7 (2004)
   November
   September
   July
   June
   May
   April
   March
   February (Part 2)
   February
   January (Part 2)
   January

Volume 6 (2003)
   December
   November (Part 2)
   November
   September
   August (Part 2)
   August
   July (Part 2)
   July
   June (Part 2)
   June
   May (Part 2)
   May
   April (Part 2)
   April
   March (Part 2)
   March
   February (Part 2)
   February
   January (Part 2)
   January

Volume 5 (2002)
   December (Part 2)
   December
   November (Part 2)
   November
   October (Part 2)
   October
   September (Part 2)
   September
   August (Part 2)
   August
   July (Part 2)
   July
   June (Part2)
   June
   May (Part 2)
   May
   April (Part 2)
   April
   March (Part 2)
   March
   February (Part 2)
   February
   January (Part 2)
   January

Volume 4 (2001)
   December (Part 2)
   December
   November (Part 2)
   November
   October (Part 2)
   October
   September (Part 2)
   September
   August (Part 2)
   August
   July (Part 2)
   July
   June (Part 2)
   June
   May (Part 2)
   May
   April (Part 2)
   April
   March (Part 2)
   March
   February (Part 2)
   February
   January (Part 2)
   January

Volume 3 (2000)
   December (Part 2)
   December
   November (Part 2)
   November
   October (Part 2)
   October
   September (Part 2)
   September
   August (Part 2)
   August
   July (Part 2)
   July
   June
   May
   April
   March
   February
   January

Volume 2 (1999)
   December
   November
   October
   September
   July
   June
   May
   April
   March
   February
   January

Volume 1 (1998)
   December
   November
   October
   September

 

Beginner Tip:
Quotation Marks And Coding Errors

by Larisa Thomason,
Senior Web Analyst,
NetMechanic, Inc.

  
March 2002
Vol. 5, No. 5
 • Beginner Tip
 • CSS Tip
 • Promotion Tip
  

Misplaced or mismatched quotation marks are one of the single most common coding errors in HTML. That simple mistake can break your page display because images and other page elements may not display correctly - if at all.

Optional - But Not Really - In HTML

An attribute is a characteristic of an HTML tag that appears within the opening part of the tag. You use attributes to define color, size, alternate text, etc. In the following example, the IMG tag has three attributes: height, width, and alt. Height and width tell the browser the image's size. The browser uses that information to display the page layout more quickly. ALT is a text description of the image that is used by people with text-only browsers or assistive technologies like screen readers:

<IMG src="../images/2Lions.jpg" height="128" width="82" alt="Photo of our 2 lions">

Now technically, you could quote every attribute like we did in this example, or you could save a few keystrokes and only quote the ALT tag. It's the only one that HTML 4 requires to be in quotes.

So this example is also correct:

<IMG src=../images/2Lions.jpg height=128 width=82 alt="Photo of our 2 lions">

There's nothing wrong with this code - except that it requires you to remember which attributes require quotation marks. It's a lot safer to get into the habit of quoting all attributes every time. You'll reduce the number of coding errors and debug time.

Common Errors With Quotes

If you've written your own HTML code or tried to modify editor-generated code, you've probably made at least one of these two common mistakes:

  1. Open quotes. If you leave a quote open, the browser doesn't understand where the attribute ends. Look at this sample table code. The problem line in is bold type. Note that the border attribute has a missing quotation mark.

    <TABLE border="1 >
    <TR>
    <TD><IMG src="lions.jpg" height="128"
    width="82" alt="2 lions"></TD>
    <TD>Middle Column<TD>
    <TD>Right Column</TD>
    </TABLE>

    See what it does to the table layout?

    Table error example
  2. Nested quotes. This most often happens when you're using quotation marks inside an ALT tag like this:

    <IMG src"2Lions.jpg" height="128" width="82" alt="Our 2 "pet" lions!">

    That's interpreted as: alt="Our 2" pet "lions!" Explorer 5.x and Netscape 6.x are pretty forgiving and display the image and alt tag, but older browsers may not show the image at all.

Use one of these options to nest quotes inside an ALT tag:

  • A combination of single and double quotes: alt="Our 2 'pet' lions!"
  • Escape the character with the numeric character &#38;: alt="Our 2 &#38;pet&#38; lions!"
  • Escape the character with the named character &quot;: alt="Our 2 &quot;pet&quot; lions!"

Good HTML check and repair tools like HTML Toolbox will alert you to these types of errors and other coding problems that may break your pages.

Code For The Future

Most WYSIWYG editors are configured to automatically quote all attributes, but they do allow users to change the settings to use double quotes, single quotes, or none at all. If your editor isn't adding quotes to attributes, just check the documentation to find out how to modify the default settings.

You won't get errors by quoting attributes in cases where it's optional. You will get page errors if you neglect to quote required attributes. So why not just make a habit of enclosing all attributes in quotes? Then your HTML code will be in much better shape when you're ready to start hand-coding your pages or adding your own custom code to the editor-generated pages.

That saves you time and effort trying to locate HTML code errors. As an added benefit, you take a step towards getting your HTML code ready to convert to XHTML. The XHTML specifications require that all attributes be inside quotes. You'll save a lot of time in the future if you ever want to convert your HTML documents to XHTML.



Rate This Tip:
Not Useful Useful Very Useful   
 
NetMechanic Tools
HTML Toolbox
Browser Photo
Server Check
Search Engine Starter
Search Engine Tools
GIFBot
Newsletter
HTML Tutorial and Tips
Search Engine Tutorial
Accessibility Information
Browser Problem Tutorial

Company Info
Products
About Us
Contact
Advertise
Link To Us
Jobs
Privacy Policy
Partner Programs
Press Room
RSS Feed
Support
 



Powered by Overture!

 
     
 
   
 
     


Keynote Home
Copyright © 1996-2007,
Keynote NetMechanic
All rights reserved.