Prasad G
Prasad G

Reputation: 6718

How to get images side by side in html

I am new in html. I am trying to display images side by side using html.

I knew using following code:

<div style="float:left;"> 
    <img alt="logo" src="images/logo.gif" /> 
    <img alt="background" src="images/bkgd.gif" /> 
</div> 

all img tags are in div tag.

But in my code i have taken different div tags for different images.

<div style="float:left;">
<li class="gallerybox" style="width: 185px">
    <div style="width: 185px">
        <div class="thumb" style="width: 180px;">
            <div style="margin:19.5px auto;">
                <a href="http://en.wikipedia.org/wiki/File:Marathahalli.jpg" class="image"><img alt="" src="http://upload.wikimedia.org/wikipedia/commons/thumb/f/f6/Marathahalli.jpg/150px-Marathahalli.jpg" width="150" height="91"></a>
            </div>
        </div>
        <div class="gallerytext">
            <p>View of Outer ring road from Marathahalli bridge</p>
        </div>
    </div>
</li>
<li class="gallerybox" style="width: 185px">
    <div style="width: 185px">
        <div class="thumb" style="width: 180px;">
            <div style="margin:15px auto;">
                <a href="http://en.wikipedia.org/wiki/File:Marathahalli_ring_road_side_view_8140.JPG" class="image"><img alt="" src="http://upload.wikimedia.org/wikipedia/commons/thumb/c/cc/Marathahalli_ring_road_side_view_8140.JPG/133px-Marathahalli_ring_road_side_view_8140.JPG" width="133" height="100"></a>
            </div>
        </div>
        <div class="gallerytext">
            <p>Marathahalli ORR</p>
        </div>
    </div>
</li>
<li class="gallerybox" style="width: 185px">
    <div style="width: 185px">
        <div class="thumb" style="width: 180px;">
            <div style="margin:15px auto;">
                <a href="http://en.wikipedia.org/wiki/File:Marathahalli_ring_road_side_view_8138.JPG" class="image"><img alt="" src="http://upload.wikimedia.org/wikipedia/commons/thumb/3/37/Marathahalli_ring_road_side_view_8138.JPG/133px-Marathahalli_ring_road_side_view_8138.JPG" width="133" height="100"></a>
            </div>
        </div>
        <div class="gallerytext">
            <p>Marathahalli ORR side snap</p>
        </div>
    </div>
</li>
<li class="gallerybox" style="width: 185px">
    <div style="width: 185px">
        <div class="thumb" style="width: 180px;">
            <div style="margin:15px auto;">
                <a href="http://en.wikipedia.org/wiki/File:Marathahalli_ring_road_side_view_8151.JPG" class="image"><img alt="" src="http://upload.wikimedia.org/wikipedia/commons/thumb/f/fc/Marathahalli_ring_road_side_view_8151.JPG/133px-Marathahalli_ring_road_side_view_8151.JPG" width="133" height="100"></a>
            </div>
        </div>
        <div class="gallerytext">
            <p>Innovative multiplex theater</p>
        </div>
    </div>
</li>
<li class="gallerybox" style="width: 185px">
    <div style="width: 185px">
        <div class="thumb" style="width: 180px;">
            <div style="margin:15px auto;">
                <a href="http://en.wikipedia.org/wiki/File:Marathahalli_ring_road_side_view_8149.JPG" class="image"><img alt="" src="http://upload.wikimedia.org/wikipedia/commons/thumb/4/40/Marathahalli_ring_road_side_view_8149.JPG/133px-Marathahalli_ring_road_side_view_8149.JPG" width="133" height="100"></a>
            </div>
        </div>
        <div class="gallerytext">
            <p>Aisshwaria Opulance Apartment at Marathahalli ring road</p>
        </div>
    </div>
</li>
</div>

Please help me.

Upvotes: 1

Views: 15651

Answers (2)

Deepak Kamat
Deepak Kamat

Reputation: 1980

I don't actually understood what you want your code to do. But still I think this might (may not) help you. (Use classes and internal CSS styles not inline)

<div class='img-container'>
<img src='image.jpg'/>
<img src='image2.jpg'/>
</div>

And the CSS to make the images appear side by side :

.img-container img {
display:inline-block;
width:100px; /* or whatever you want*/
height:100px; /* same as above */
}

If this is not what you are looking for then please create a fiddle and update your question with the link.

Upvotes: 1

Barnee
Barnee

Reputation: 3389

Try this:

li {
    float: left;
}

Upvotes: 2

Related Questions