-2

I am trying to put some text beside a photo and I want this text to flow under the image. I used figure tag and figcaption tag but it doesn't work.

<figure>
  <img class="row2" src="http://placekitten.com/150/150">
  <figcaption class="text">Email filtering is the processing of email to organize it according to specified criteria. </figcaption>
</figure>
Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335
Nada
  • 1

3 Answers3

0

If you just want your caption to be same size as image and below it. Give a width to figure

figure{
  width: 300px;
}
img{
  max-width: 100%;
  display: block;
}
<figure>
  <img class="row2" src="http://placekitten.com/450/450">
  <figcaption class="text">Email filtering is the processing of email to organize it according to specified criteria. </figcaption>
</figure>
Sayog
  • 720
  • 6
  • 8
0

float will make your text beside and below.

img {
  float: left;
}
<!DOCTYPE html>
<html lang="">

<head>
  <title>Test</title>
</head>

<body>
  <figure>
    <img class="row2" src="http://placekitten.com/150/150">
    <figcaption class="text">Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It
      has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop
      publishing software like Aldus PageMaker including versions of Lorem Ipsum It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has
      a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like</figcaption>
  </figure>
</body>

</html>
GMAC
  • 788
  • 4
  • 23
0

Use the flexbox for best result.

If you click the 'Full page' in the code snippet then you'll see image + text side by side.

figure {
  display: flex;
  flex-flow: row wrap;
}
img.row2,
figcaption.text {
  display: block;
  margin: 0;
  box-sizing: border-box;
}
img.row2 {
  width: 40%;
  height: auto;
  border: 0;
}
figcaption.text {
  width: 60%;
  padding: 20px;
}
/* small devices */
@media (max-width: 767px) {
  img.row2,
  figcaption.text {
    width: 100%;
  }
}
<!-- in head section -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">

<figure>
  <img class="row2" src="http://placekitten.com/150/150">
  <figcaption class="text">Email filtering is the processing of email to organize it according to specified criteria. </figcaption>
</figure>
bron
  • 1,457
  • 1
  • 9
  • 18