The a href tag causes problems together with image tags.
scenario 1:
insert image
select image by clicking once on the image (resize squares appears)
Insert link by clicking on the Insert Link button.
Result: a href tag appear before img tag: <a href=url></a><img src=image>
scenario2:
insert image
select image by placing the cursor before the picture and pressing Shift+ArrowRight.
Insert link by clicking on the Insert Link button.
Result: a href tag is inserted correctly: <a href=url><img src=image></a>
scenario3:
Complete scenario2
Select the image and click on the Insert Image button (or simply double-click on the image)
Change border size and click insert.
Result: img tag is replaced, and inserted before the a href tag: img src=image><a href=url><</a>
As you can see, there are several pitfalls for the average user...
Regards, Thomas