-1

I have created a html like following

<a href="http://google.com">
  <img src="C:\Users\HOME\Desktop\maxresdefault.jpg" width="100" height="100">
  <p style="clear: both;">text in the pararaph is created using html</p>
</a>
<a href="http://google.com">
  <img src="C:\Users\HOME\Desktop\maxresdefault.jpg" width="100" height="100">
  <p style="clear: both;">text in the pararaph is created using html</p>
</a>
<a href="http://google.com">
  <img src="C:\Users\HOME\Desktop\maxresdefault.jpg" width="100" height="100">
  <p style="clear: both;">text in the pararaph is created using html</p>
</a>
<a href="http://google.com">
  <img src="C:\Users\HOME\Desktop\maxresdefault.jpg" width="100" height="100">
  <p style="clear: both;">text in the pararaph is created using html</p>
</a>
<a href="http://google.com">
  <img src="C:\Users\HOME\Desktop\maxresdefault.jpg" width="100" height="100">
  <p style="clear: both;">text in the pararaph is created using html</p>
</a>
<a href="http://google.com">
  <img src="C:\Users\HOME\Desktop\maxresdefault.jpg" width="100" height="100">
  <p style="clear: both;">text in the pararaph is created using html</p>
</a>
<a href="http://google.com">
  <img src="C:\Users\HOME\Desktop\maxresdefault.jpg" width="100" height="100">
  <p style="clear: both;">text in the pararaph is created using html</p>
</a>
<a href="http://google.com">
  <img src="C:\Users\HOME\Desktop\maxresdefault.jpg" width="100" height="100">
  <p style="clear: both;">text in the pararaph is created using html</p>
</a>
<a href="http://google.com">
  <img src="C:\Users\HOME\Desktop\maxresdefault.jpg" width="100" height="100">
  <p style="clear: both;">text in the pararaph is created using html</p>
</a>
<a href="http://google.com">
  <img src="C:\Users\HOME\Desktop\maxresdefault.jpg" width="100" height="100">
  <p style="clear: both;">text in the pararaph is created using html</p>
</a>
<a href="http://google.com">
  <img src="C:\Users\HOME\Desktop\maxresdefault.jpg" width="100" height="100">
  <p style="clear: both;">text in the pararaph is created using html</p>
</a>
<a href="http://google.com">
  <img src="C:\Users\HOME\Desktop\maxresdefault.jpg" width="100" height="100">
  <p style="clear: both;">text in the pararaph is created using html</p>
</a>
<a href="http://google.com">
  <img src="C:\Users\HOME\Desktop\maxresdefault.jpg" width="100" height="100">
  <p style="clear: both;">text in the pararaph is created using html</p>
</a>
<a href="http://google.com">
  <img src="C:\Users\HOME\Desktop\maxresdefault.jpg" width="100" height="100">
  <p style="clear: both;">text in the pararaph is created using html</p>
</a>

I want all the images to appear in a grid and also to have the text below the respective images. If the lenght of text is more than image then the text should continue in 2nd line. You can check what i exactly want in the below image. However in the image there is a separate background behind the text which is not much important to me.

Image is available @ this link : http://imageart.webs.com/html%20output.png

3 Answers3

1

Just do something like what Vucko suggested since both the image and the p are wrapped inside an a

a { 
 display:inline-block; /* Aligns them side by side */
 width: 100px; /* You need a fixed width */
 margin: 0 10px 10px 0; /* Just for spaces */
}

See working example here

Note We targeted a because it's in this case the parent to the image and p respectively.

Sleek Geek
  • 4,638
  • 3
  • 27
  • 42
0

try this simple table align..

 <table width="100%">
    <tr><td>
    <a href="http://google.com">
      <img src="C:\Users\HOME\Desktop\maxresdefault.jpg" width="100" height="100">
      <p style="clear: both;">text in the pararaph is created using html</p>
    </a></td>
    <td>
    <a href="http://google.com">
      <img src="C:\Users\HOME\Desktop\maxresdefault.jpg" width="100" height="100">
      <p style="clear: both;">text in the pararaph is created using html</p>
    </a></td>
    <td>
    <a href="http://google.com">
      <img src="C:\Users\HOME\Desktop\maxresdefault.jpg" width="100" height="100">
      <p style="clear: both;">text in the pararaph is created using html</p>
    </a></td>
    </tr>
    <tr>
    <td>
    <a href="http://google.com">
      <img src="C:\Users\HOME\Desktop\maxresdefault.jpg" width="100" height="100">
      <p style="clear: both;">text in the pararaph is created using html</p>
    </a></td>
    <td>
    <a href="http://google.com">
      <img src="C:\Users\HOME\Desktop\maxresdefault.jpg" width="100" height="100">
      <p style="clear: both;">text in the pararaph is created using html</p>
    </a></td>
    <td>
    <a href="http://google.com">
      <img src="C:\Users\HOME\Desktop\maxresdefault.jpg" width="100" height="100">
      <p style="clear: both;">text in the pararaph is created using html</p>
    </a></td>
    </tr>
    <tr>
    <td>
    <a href="http://google.com">
      <img src="C:\Users\HOME\Desktop\maxresdefault.jpg" width="100" height="100">
      <p style="clear: both;">text in the pararaph is created using html</p>
    </a></td>
    <td>
    <a href="http://google.com">
      <img src="C:\Users\HOME\Desktop\maxresdefault.jpg" width="100" height="100">
      <p style="clear: both;">text in the pararaph is created using html</p>
    </a></td>
    <td>
    <a href="http://google.com">
      <img src="C:\Users\HOME\Desktop\maxresdefault.jpg" width="100" height="100">
      <p style="clear: both;">text in the pararaph is created using html</p>
    </a></td>
    </tr>
    <tr>
    <td>
    <a href="http://google.com">
      <img src="C:\Users\HOME\Desktop\maxresdefault.jpg" width="100" height="100">
      <p style="clear: both;">text in the pararaph is created using html</p>
    </a></td>
    <td>
    <a href="http://google.com">
      <img src="C:\Users\HOME\Desktop\maxresdefault.jpg" width="100" height="100">
      <p style="clear: both;">text in the pararaph is created using html</p>
    </a></td>
    <td>
    <a href="http://google.com">
      <img src="C:\Users\HOME\Desktop\maxresdefault.jpg" width="100" height="100">
      <p style="clear: both;">text in the pararaph is created using html</p>
    </a></td>
    </tr>
    <tr>
    <td>
    <a href="http://google.com">
      <img src="C:\Users\HOME\Desktop\maxresdefault.jpg" width="100" height="100">
      <p style="clear: both;">text in the pararaph is created using html</p>
    </a></td>
    <td>
    <a href="http://google.com">
      <img src="C:\Users\HOME\Desktop\maxresdefault.jpg" width="100" height="100">
      <p style="clear: both;">text in the pararaph is created using html</p>
    </a></td>
    </tr>
    </table>
Sarath
  • 2,318
  • 1
  • 12
  • 24
0
<figure>
<img scr='#'>
<figcaption>I am under the image</figcaption>
</figure>

HTML 5 solution http://www.w3schools.com/tags/tag_figcaption.asp

See also this post How to align caption underneath image

Community
  • 1
  • 1
Michelangelo
  • 5,888
  • 5
  • 31
  • 50