Consider this being slipped into some HTML file right after a <body> tag and before some text:
<div style="width:100%; height=320pix; background-color:black">
<img src="logo.jpg">
</div>
For me, this creates a black “banner” at the top of the browser page, with the logo image (320pix high) aligned to the left. How can I move it to the right and leave the text exactly as is? I would like to know the simplest addition to this code to achieve that. When I specify style="float:right" in the <img ...> tag line, the text that follows wraps around it, destroying the banner effect.
However… if I transfer the same elements into a <style>...</style> block within the HTML, and include an img{float:right;} everything works fine. I just do not understand why the floating behaviour should be different between the two approaches. My head is about to explode…
A possible lead – This question indicates that it should be simple, but when I try precisely the code given, it still does not work. Could it be a !DOCTYPE or similar issue? I am using Firefox 15.0.1 as my browser.
Give the DIV containing the image a relative position. This will allow you to position the image absolutely within it.
Adjust the ‘right’ to position the image to your liking.