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+.

2 thoughts on “Blogger adding an extra clear: both div to posts”

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

Leave a Reply

Your email address will not be published. Required fields are marked *