I wrote the code below, and it kind of works except that margins are not working. See the image below. I want margins between item
s and between the image and the text. How can I get the layout I want? I don't have to use float=left
if there is a better way.
.item {
clear: both;
margin-bottom: 1em;
display: block;
}
.leftImage {
float: left;
}
.rightText {
margin-left: 1em;
}
<div class="item">
<img class="leftImage" src="http://via.placeholder.com/640x360" />
<p class="rightText">Hello <br/> world.</p>
</div>
<div class="item">
<img class="leftImage" src="http://via.placeholder.com/640x360" />
<p class="rightText">Hello <br/> world.</p>
</div>