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];
 if(curDiv.parentNode.className=='postingBlock'){
  var block=curDiv.parentNode;
  html=block.innerHTML;
  html=html.replace(/()?
/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+.

Advertisements
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

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s