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!     
 

Search for:


Your Email:

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



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

 

HTML Tip:
Beware of the Carriage Return

by Tom Dahm,
Chief Operations Officer,
NetMechanic, Inc.

  
November 1998
Vol. 1, No. 3
 • HTML Tip
 • New Tool
 • Server Tip
  

Be careful where you put carriage returns within your HTML documents. This can sometimes lead to unwanted white space in your page.

In theory HTML doesn't pay attention to white space within your source document. In practice, your browser will interpret a carriage return as a single character of white space.

Take the following HTML source as an example:

<b>hello
h
e
l
l
o
</b>

You might think this would result in the word "hello" being displayed twice with identical rendering. In reality the second "hello" will be rendered with extra white space between each letter, as shown in the image below.

How Netscape Navigator renders the above HTML code

The extra space is added by your browser to prevent adjacent words on different lines from running together. This behavior is consistent across most versions of all the major browsers. We've seen this behavior in Netscape Navigator 4.02, Navigator 3.01, Internet Explorer 4.0, Explorer 3.0 and even Lynx 2.5.

Unless you are aware of this effect, it can lead to unintended consequences. Consider this example:

Line 1: <img src="/logo_left_v2.gif" border=1>
        <img src="/logo_right_v2.gif" border=1>
Line 2: <br>
Line 3: <img src="/logo_left_v2.gif" border=1>
Line 4: <img src="/logo_right_v2.gif" border=1>

      

This HTML source shows two separate images that should be rendered adjacent to each other. Line 1 of this code places both image tags on the same source line. Notice that your browser will display these images with their borders touching, as shown below.

logologo

Lines 3 and 4 show the same source, only with a carriage return inserted between the image tags, breaking the source up over two lines. This causes your browser to insert a space between the images, as shown below.

logo logo

This effect of this isn't necessarily bad. We use this in the NetMechanic logo to force a little separation between the images. But if you don't know about this HTML quirk you can spend many frustrating hours tracking down the source of that little gap!



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.