I am trying to position an image and text within separate containers using div
.
The desired layout is to have the img
floated left and the text centered on the page, but I am having trouble achieving this. Each element has its own div
.
Can you provide assistance on how to accomplish this?
Below is the CSS and HTML code I am currently working with:
#ImageDiv {
position: relative;
margin: auto;
width: 250px;
height: auto;
float: left;
}
#TextDiv {
position: relative;
width: auto;
height: auto;
text-align: center;
margin: auto;
float: left;
}
#ContainerDiv {
text-align: center;
width: auto;
height: 104px;
background-color: rgb(252, 251, 249);
position: relative;
border-radius: 5px;
border-style: inset;
border-width: 2px;
font-size: 22px;
color: rgb(46, 84, 0);
margin: auto;
}
<div id="ContainerDiv">
<div id="ImageDiv">
<img style="float: left; margin-right: 5px;" src="imagePath" alt="Alternate Text" />
</div>
<div id="TextDiv">
<h5>Some Text Goes Here...</h5>
</div>
</div>