Have you heard of the programming language, HTML (HyperText Markup Language) and CSS (Cascading Style Sheets)? If you have, then it is good, and if you have not, then you will become aware of these two languages through this post and other articles about programming languages on this blog.

You will learn how to make stylish, standout and responsive image gallery with simple HTML and CSS photo gallery codes. We’ve made it easy with free template you can follow line after line.

Before going further and digging dip, you’re advised to open notepad, and save the file with name index.html in a folder (name the folder, gallery). You should make another folder with the name, images in gallery folder. You should put three images of the same size, for example 400*400 size images in images folder.  Write the following codes in index.html file:

<!doctype html>
<html lang=”en”>
<head>
<meta charset=”utf-8″/>
<title>Gallery</title>
<link rel=”stylesheet” href=”style.css”/>
<body>
</body>
</html>

In the body (between <body> and</body>) of your HTML, you should write the following codes:

<h1>Gallery</h1>
<div id=”gallery”>
<ul>
<li>
<img src=”hxxps://drsamrobbins.com/wp-content/uploads/2014/03/apples-burn-fat-400×400.jpg” class=”pic”/>
<label>Caption Here</label>
</li>
<li>
<img src=”hxxps://noao.edu/image_gallery/images/d2/m51-400.jpg” class=”pic”/>
<label>Caption Here</label>
</li>
<li>
<img src=”hxxps://i.pinimg.com/736x/9e/4a/1e/9e4a1e2ce8fdd5e8f2eafba6f7c34bf0–glitter-wallpaper-black-wallpaper.jpg” class=”pic”/>
<label>Caption Here</label>
</li>
</ul>
</div>
<!—that’s how comments are made in HTML (start comment)(

Note: <div> is an HTML tag that divides HTML body into portions, and h1 is a heading tag, <ul> is a tag for unordered list, <li> is a tag for list, and class is a child of id in HTML. I have used links to generate pictures in HTML body rather than using the pictures in the folder.

Note 2: Change the hxxp in bold to http

<!—that’s how comments are made in HTML (end comment)(

 

Now you should open a blank notepad document, and you should name it style.css. Put style.css file in the same folder where your index.html file is. In the style.css file, write following codes (note that comments in stylesheet files are given by typing // next to semicolon):

h1
{
text-shadow:gray 3px 3px 3px;//will give text a gray shade
box-shadow:gray 3px 3px 3px 3px;//will give box a gray shade
}

#gallery ul li
{
border:5px solid black;// will create a border of 5 px with black colour
float:left;//will move the images to the left
width:27%;//images will be created with 27% width
margin:1%; //will place images at a distance of 1% from one another
position:relative;//image will be positioned
list-style:none;//will hide the bullet points
}

#gallery ul li .pic
{
width:100%;// image will be made with 100% width
height:200px;//image will be 200px in height
-webkit-transition:-webkit-transform 3s linear;// it’s a CSS3 property for transformation
}

#gallery ul li .pic:hover
{
-webkit-transform:rotate(360deg);//will rotate the image to 360 degree; you can also use 180deg instead of 360deg
}

#gallery ul li label
{
background-color:black;//will color the background of label, black
color:white;//will color the text of label, white
bottom:0%;//will fix the label at bottom
opacity:0.5;//will make the background color 50% lighter
position:absolute;//it is often used with relative property
height:30px;//height of the label will become 30px
width:100%;//will make the width of label, 100%
text-align:center;//will align the text in center
-webkit-transition:height 2s linear;//will call –webkit-transition property
}
#gallery ul li label:hover
{
height:80px;//caption will rise to 80px, because of hover command
 
}

You can use above codes to try out making a standout gallery yourself. Remember –webkit-transition property is not supported in Internet Explorer, you should use the Google Chrome or Opera browser to test above codes. You should remember that ids are called by # in stylesheet, and classes are called by dot (.) in stylesheet

Interactive and responsive gallery looks more pretty, hence you should also try to make standout galleries. This is the same way how Google shows images on browser. HTML and CSS languages are not very difficult to learn, and you need to give time to study these languages as they need practice.

The more you practice HTML and CSS, the more command you will have over HTML and CSS. HTML and CSS are interesting languages, hence you will not face problem learning it.

Following are some of the things about HTML and CSS that you must know about:

  • HTML tags are both open and closed. For example, <p> is an open paragraph tag and </p> is a close paragraph tag.
  • <h2>, <h3>, <h4>, <h5>, and <h6> are heading tags in HTML, whereas <h6> has the lowest size, and <h2> has bigger size than h3,h4, and h5 respectively
  • <br>This tag breaks the line in HTML

In order to create a circle through HTML & CSS, programmer must define an item either through id or class in HTML, for example <div id=”box”></div>, then the programmer must define same height and width in style sheet with background-color and border-radius as shown below:

#box

{

width:200px;

height:200px;

background-color:blue;//will color the background, blue

border-radius:100%;//will make square a circle

}

font-style, font-weight, cursor, padding, margin, and * are some of the commands that are often used in CSS

 

How much knowledge have you gained about HTML and CSS through this post? Now, you can make a gallery just like Google images gallery. You are also aware of various html tags and stylesheet code now. You should carefully go through this post again, and you must also open notepad to practice creating standout gallery through HTML and CSS.

 

Contributor:

John, an expert programmer. He has experience of long-term in Programming, and he has command over HTML, CSS, JavaScript, SQL, and PHP. And He also provide assignment writing service to software engeering student and He often creates articles on Programming. He works in software house where his job is to come up with new ideas for programming every day.

 

How to Create Stylish & Responsive Image Gallery with Free Simple HTML & CSS Code Template

5 thoughts on “How to Create Stylish & Responsive Image Gallery with Free Simple HTML & CSS Code Template

  • November 3, 2017 at 3:56 pm
    Permalink

    thanks for this…..let me learn a bit

    Reply
  • February 3, 2018 at 9:19 am
    Permalink

    What about html or css image grid style with different sizes template to create responsive image gallery with bootstrap.

    Reply
  • February 21, 2018 at 9:20 pm
    Permalink

    I got the tricks in your post but how can we make the css image gallery responsive and show with thumbnails. A simple template would also be appreciated. Thanks

    Reply
  • March 23, 2018 at 7:49 am
    Permalink

    Thanks for sharing amazing post

    Reply
  • June 6, 2018 at 9:01 pm
    Permalink

    Well written and very helpful, still not able to replicate this tutorial and I’ve just sent email to you for help. Kindly reply.

    Reply

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.