Blogger adding an extra clear: both div to posts

Lots of people have noticed recently that Blogger has started publishing posts with a

tag before the posting text. This broke my layout and have me invalidly nested tags since I was including the opening and closing

tags in the template. The extra

tag meant that the browser closed the previous block element (the

) and then after closing the

went back to put the first paragraph of content straight after. This meant my posting class wasn’t being applied so the first paragraph of every post didn’t look right. It also broke the already broken HTML on the site.

So, since it was annoying for me, I’ve written a partial fix in JavaScript. Paste the code below into your Blogger template just before the closing tag. This is important as it needs to be in the code after all the content.

var allDivs = document.getElementsByTagName("div");
for(var i=0;i<allDivs.length;i++){
 var curDiv=allDivs[i];
  var block=curDiv.parentNode;
/gi,''); block.innerHTML=html; } }

I’ve tested it in IE6 and Firefox so far, and I’m not really bothered about the rest at the moment although it should work in IE5+.

This entry was posted in Programming. Bookmark the permalink.

2 Responses to Blogger adding an extra clear: both div to posts

  1. Karl Bunyan says:

    Okay – adding a comment to my own post, it can be turned off within Settings -> Formatting and change ‘Enable float alignment’ to ‘No’.

  2. Bealers says:

    The original solution is better.

Leave a Reply to Karl Bunyan Cancel reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s