CSS align images and text on same line
You can either use (on the h4 elements, as they are block by default)
display: inline-block;
Or you can float the elements to the left/rght
float: left;
Just don't forget to clear the floats after
clear: left;
More visual example for the float left/right option as shared below by @VSB:
<h4> <div style="float:left;">Left Text</div> <div style="float:right;">Right Text</div> <div style="clear: left;"/></h4>
CSS Positioning with Text and Images on Same Line
You're making it a little more complicated than it needs to be. Just put two elements as wrappers (one you already have in alignImage
, set them to display as inline-block
and then put the vertical-align
to middle
, top
, or whatever you like. I got rid of all the bizarre padding, which was messing with the display as well. Looks like that was a holdover from your vertically stacked layout.
Edit – You've also got two elements with the ID alignPhoto
. You really, really shouldn't do that. If you need to style two different elements with one rule, please use classes instead.
#alignPhoto { display: inline-block; vertical-align: middle;}#alignPhoto img { border-radius: 100%;}#alignImage { position: relative;}.alignText { display: inline-block; vertical-align: middle;}.titleBoldText { text-align: right; }
<div class="alignText"> <div class="titleBoldText">Mary Smith</div> <div id=alignCompany class="titleText">Morris Realty and Investments</div></div><div id="alignPhoto"> <div class="circle" id=image role="image"> <img src="http://placehold.it/42x42"> </div></div><br>
Related Topics
Symetric Div with Background Image Without Clip-Path
Difference Between Applying CSS Rules to HTML Compared to Body
HTML5 Standards of Nesting Div in Li or Dl
Embed Youtube Code Is Not Working in HTML
How to Add Padding to Select Options via CSS
Vertically Center and Left-Align a Column of Flex Items
Insert HTML with Scripts That Should Run
Is The Marquee HTML Element Supported by All Browsers Yet
Word-Wrap Break-Word Does Not Work in This Example
:Before &&: After Pseudo Elements Not Showing Firefox
Dropdownlistfor Will Not Show The Correct Selection
What Does "Top: 0; Left: 0; Bottom: 0; Right: 0;" Mean