Here's how I did it: I gave the #outer CSS style display:inline-block , and then just placed it in another div using css display:block to make sure #outer stayed on a separate line:
CSS
#outer { text-align: center; border-style: solid; border-width: 1px; border-color: #000000; height: 50px; width:auto; display:inline-block; } #image { float: right; width: 50px; } #element_block { display:block; }
HTML
Some content above div <div id="element_block"> <div id="outer"> Text inside div<div id="image">IMG</div> </div> </div> Some content below div
Demo
Daniel Lisik
source share