How to align images side by side with CSS?

CSSWeb DevelopmentFront End Technology

Following is the code to align images side by side using CSS −

Example

 Live Demo

<!DOCTYPE html>
<html>
<head>
<style>
* {
   box-sizing: border-box;
}
.imageColumn {
   float: left;
   width: 25%;
   padding: 10px;
}
h1{
   text-align: center;
}
</style>
</head>
<body>
<h1>Images Aligned Side by Side example</h1>
<div class="alignRow">
<div class="imageColumn">
<img src="https://i.picsum.photos/id/811/400/400.jpg" alt="Snow" style="width:100%">
</div>
<div class="imageColumn">
<img src="https://i.picsum.photos/id/871/400/400.jpg" alt="Forest" style="width:100%">
</div>
<div class="imageColumn">
<img src="https://i.picsum.photos/id/471/400/400.jpg" alt="Mountains" style="width:100%">
</div>
<div class="imageColumn">
<img src="https://i.picsum.photos/id/271/400/400.jpg" alt="Snow" style="width:100%">
</div>
</div>>
</body>
</html>

Output

The above code will produce the following output −

raja
Published on 06-Apr-2020 13:19:09
Advertisements