Forum Moderators: open

Message Too Old, No Replies

blank lines at beginning of html doc

         

legster

1:13 pm on Jun 10, 2002 (gmt 0)

10+ Year Member



We use Cold Fusion, and the templates end up rendering a ton of blank lines at the beginning of our html documents after they hit the browser. To be more exact, on one of our pages there are 680 blank lines before you get to the opening html tag!

I know it has been discussed in the past on whether search engine spiders only read so far down a document. Do they skip blank lines, or count them?

Also, when I drag over the blank lines, it appears to be highlighting hidden text. Any one have any idea if any of this matters?

lorax

1:28 pm on Jun 10, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



also, when I drag over the blank lines, it appears to be highlighting hidden text. Any one have any idea if any of this matters?

Spaces. Your CFML code has something that's generating spaces when the CF Server parses the page.

As for what the spiders see - I don't believe they'll be a problem. But I'm no expert on SEs.

brotherhood of LAN

2:08 pm on Jun 10, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Hi Legster,

>>I know it has been discussed in the past on whether search engine spiders only read so far down a document. Do they skip blank lines, or count them?

They would "count them" in respect of file size. I'm not sure whether hard line breaks are 1 byte or 2 bytes, but nonetheless they make file sizes bigger.

Also, people in here have mentioned that it is better to have a high "content to code ratio". No doubt empty space and line breaks will count as "code".

In regards to the software, what is the hiddent text that is shown that "should not" be there?

frogg

3:57 pm on Jun 10, 2002 (gmt 0)

10+ Year Member



Extra whitespace at the top of a dynamically generated page is common. It's an artifact from how you've embedded your server-side code into the HTML page. More often than not, you'll have a lot of code at the top of the page, and this is where you'll notice this first - but you'll also probably get blank lines in your HTML at other places where s-s code has been embedded else you've embedded code into your HTML.

I can only speak for PHP, JSP, ASP and CFML - but it's basically a result of having stuff like this in your HTML:-

<%
// server-side code
%>
<xmlStyle:magicMarkupTag/>
<%
// more server-side code
%>
<xmlStyle:anotherMagicMarkupTag/>
<html>
<head>

...etc.

What you will notice in the above is that there are newline chars (CR/LFs) appearing outside of the server-side code sections (or CF/XML markup), ie: after the '%>' tokens, and after the '/>' tokens.

This whitespace was probably put there by you, to enhance readability and maintainability at development time - a very good practise in itself.

When the ASP/JSP/PHP/etc parser that interprets the page, it removes what it recognises as code (and otherwise, um, 'executes the page') you are left with the stuff that was between the code sections -- including any terminating newlines -- which are often overlooked when seen on their own (in ones, twos and threes), or at the end of lines of text.

(This still throws me out sometimes though: there's nothing more puzzling than choosing 'View Source' only to see an empty window when you were expecting to see a load of HTML!! ..and then I remember to scroll down!! ;) )

hth

frogg

4:04 pm on Jun 10, 2002 (gmt 0)

10+ Year Member



..and to prevent this, you would change my example above so it reads:-

<%
// server-side code
%><xmlStyle:magicMarkupTag/><%
// more server-side code
%><xmlStyle:anotherMagicMarkupTag/><html>
<head>

or

<%
// server-side code
%><xmlStyle:magicMarkupTag
/><%
// more server-side code
%><xmlStyle:anotherMagicMarkupTag
/><html>
<head>

..but I bet you already knew that! :)

rewboss

3:12 pm on Jun 11, 2002 (gmt 0)

10+ Year Member



there's nothing more puzzling than choosing 'View Source' only to see an empty window when you were expecting to see a load of HTML!!

Some people use it as a way to prevent (amateur) pirates from stealing code. A nice extra touch is to include a comment right at the top, like this:

<!-- SSI Error: Source code not available -->

Often, people who are dumb enough to want to steal your source code are dumb enough to be taken in by this trick.

I'm not sure whether hard line breaks are 1 byte or 2 bytes

If the code was written on a UNIX machine, it's 1 byte; if it was written on a Windows machine, it's 2 bytes.