Wordpress & Shopify Experts

Wordpress & Shopify Experts

How to create responsive image gallery using html and css?

Hello Friends, Today in this blog you’ll learn how to create a How to create responsive image gallery using html and css?. This is for beginners who want to learn new stuff using HTML & CSS. Recently, I have shared a How to create pagination using html css? | Now it’s time to create Responsive image gallery using   HTML & CSS.

Video tutorial of Responsive Image Gallery using HTML and CSS

You may also like:

In the video, you’ve seen the css image gallery. There are many different ways to create this image grid html css one of which is the way we have designed it.

Responsive image gallery using html and css?s[Source Codes]

So to create this, Image Gallery you have to create three different files. The 3 files are index.html , style.css & script.js. Remember when you create an HTML file don’t forget to add a .html extension on HTML file and .css extension to your style file. 


Let’s create a Js file with the name of script.js and paste the below codes. Remember you’ve to create a file with a .js extension

      delegate: 'a',
      type: 'image',
        enabled: true


Let’s create a Cascading Style Sheet(CSS) file with the name of style.css and paste the below codes in your CSS file. Remember you’ve to create a file with a .css extension


					@import url('');

  margin: 0;
  padding: 0;
  font-family: 'Poppins', sans-serif;
  box-sizing: border-box;
  background: #4f4d4d;

  width: 100%;
  padding: 50px 0;

  width: 100%;
  max-width: 1300px;
  margin: auto;
  padding: 20px 20px;

.gallery-section h1{
  font-size: 4vw;
  padding-bottom: 20px;
  text-align: center;
  text-transform: uppercase;
  color: #fff;

.gallery-section .gallery a {
  padding: 10px;

  width: 180px;
  height: 4px;
  background: #333;
  margin: 60px auto;

.gallery-section .gallery{
  display: flex;
  flex-wrap: wrap-reverse;
  justify-content: center;

.gallery-section .image{
  flex: 25%;
  overflow: hidden;
  cursor: pointer;

.gallery-section .image img{
  width: 100%;
  height: 100%;
  transition: 0.4s;
  border-radius: 25px;

.gallery-section .image:hover img{
  transform: scale(1.6);

@media screen and (max-width:960px) {
  .gallery-section .image{
    flex: 33.33%;

@media screen and (max-width:768px) {
  .gallery-section .image{
    flex: 50%;

  .gallery-section h1{
    font-size: 22px;

@media screen and (max-width:480px) {
  .gallery-section .image{
    flex: 100%;


Now create a Hypertext Markup Language(HTML) with the name of index.html and paste the below codes in your HTML file. Remember you’ve to create a file with a .html extension


					<!DOCTYPE html>
<!-- Created By MultiWebPress - -->
<html lang="en" dir="ltr">
    <meta charset="utf-8">
    <link rel="stylesheet" href="style.css">
    <script src=""></script>
    <script src=""></script>
    <link rel="stylesheet" href="">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <div class="gallery-section">
      <div class="inner-width">
        <h1>Responsive Image Gallery</h1>
        <div class="gallery">

          <a href="img/1.jpg" class="image">
            <img decoding="async" src="img/1.jpg" alt="">

          <a href="img/2.jpg" class="image">
            <img decoding="async" src="img/2.jpg" alt="">

          <a href="img/3.jpg" class="image">
            <img decoding="async" src="img/3.jpg" alt="">

          <a href="img/4.jpg" class="image">
            <img decoding="async" src="img/4.jpg" alt="">

          <a href="img/5.jpg" class="image">
            <img decoding="async" src="img/5.jpg" alt="">

          <a href="img/6.jpg" class="image">
            <img decoding="async" src="img/6.jpg" alt="">

          <a href="img/7.jpg" class="image">
            <img decoding="async" src="img/7.jpg" alt="">

          <a href="img/8.jpg" class="image">
            <img decoding="async" src="img/8.jpg" alt="">

    <script src="script.js"></script>


After creating these two files & pasting codes, now run the files in your browser. You can run to any browser you have on your computer. (Google Chrome, Firefox, Internet explorer etc.)

That’s all, now you’ve successfully created responsive image gallery html css. If your code does have any bugs/errors/ or you’re facing any problems, then please comment down below or contact us from the contact us page.

Hope you enjoyed reading and watching the video. Please do like and subscribe to my youtube channel & follow me on Instagram.

Thanks in Advance!



Leave a Comment

Your email address will not be published. Required fields are marked *