I am new to HTML and I want the text to be under the image to the right.
I have tried using float: right;
but then the text is beside the image to the right.
.image-container {
position: absolute;
text-align: right;
}
.image {
max-width: 100%;
height: auto;
margin-left: 10px;
float: right;
}
.text {
text-align: right;
margin-top: 10px;
}
<div id="image-container">
<img src="Safwon.png" alt="Picture of the author" width="150" height="200" class="image" />
<div class="text">This is me</div>
</div>
3
Answers
You have specified
image-container
to your<div>
as anid
but in your CSS, you wrote it as aclass
therefore your code didn’t work. Change.image-container
to#image-container
.Add the rule
clear: right;
to your other.text
div rules