I want 3 images side by side with caption, at the moment I have 3 images going from top to bottom, with the caption on the left, not on the centre. How do I make the images appear side by side with caption in the middle? Thanks.
<div class="image123">
<img src="/images/tv.gif" height="200" width="200" style="float:left">
<p>This is image 1</p>
<img class="middle-img" src="/images/tv.gif"/ height="200" width="200">
<p>This is image 2</p>
<img src="/images/tv.gif"/ height="200" width="200">
<p>This is image 3</p>
</div>
Try using this format
This will give you a real caption (just add the 2nd and 3rd imgs using
Float:left
like others suggested)Not really sure what you meant by "the caption in the middle", but here's one solution to get your images appear side by side, using the excellent
display:inline-block
:Try this.
CSS
HTML
In your CSS:
I suggest to use a container for each
img
p
like this:Then apply
float:left
to each container. I add and5px
margin right
so there is a space between each image. Also alway close your elements. Maybe in htmlimg
tag is not important to close but in XHTML is.fiddle
Also a friendly advice. Try to avoid inline styles as much as possible. Take a look here:
html
css
It's generally recommended that you use linked style sheets because:
source
fiddle
Here is how I would do it, (however I would use an external style sheet for this project and all others. just makes things easier to work with. Also this example is with html5.