Server Side Include messed up my layout

January 9, 2012 by: B.Harding

Here is what happened:

I migrated some content to an SSI and when I viewed the page it was different. The file was SHTML.

I had a div that was supposed to hug the top of the page. After, it was moved to SSI, it was pushed down 1 line.

Tools Used:

Notepad ++

The cause:

Shtml SSI streams the bytes of the included file byte for byte. The included file was saved as UTF-8 With BOM.  The BOM bytes were being sent to the client and rendered as a space. A div following a space will move to the next line because a div is a block element.

I saw the extra bytes when I viewed the raw hex response in fiddler.
When I used Notepad++ to save the file as UTF-8 without BOM the problem disappeared.

ASP server side includes don’t suffer from this, only SHTML.

For some reason I couldn’t find any sites on the web about this. The 24 hour hosting chat support were clueless. Save yourself some time and save include files as UTF-8 without BOM.

Filed under: Uncategorized

Leave a Reply