You can use a lightbox to do it.

There is a simple example in this link:

http://lokeshdhakar.com/projects/lightbox2/

Answer from Jack on Stack Overflow
๐ŸŒ
W3Schools
w3schools.com โ€บ howto โ€บ howto_css_modal_images.asp
How To Create Modal Images
Learn how to create responsive Modal Images with CSS and JavaScript. A modal is a dialog box/popup window that is displayed on top of the current page.
๐ŸŒ
W3Schools
w3schools.com โ€บ howto โ€บ howto_js_popup.asp
How To Create Popups
Alert Buttons Outline Buttons Split Buttons Animated Buttons Fading Buttons Button on Image Social Media Buttons Read More Read Less Loading Buttons Download Buttons Pill Buttons Notification Button Icon Buttons Next/prev Buttons More Button in Nav Block Buttons Text Buttons Round Buttons Scroll To Top Button ยท Login Form Signup Form Checkout Form Contact Form Social Login Form Register Form Form with Icons Newsletter Stacked Form Responsive Form Popup Form Inline Form Clear Input Field Hide Number Arrows Copy Text to Clipboard Animated Search Search Button Fullscreen Search Input Field in Navbar Login Form in Navbar Custom Checkbox/Radio Custom Select Toggle Switch Check Checkbox Detect Caps Lock Trigger Button on Enter Password Validation Toggle Password Visibility Multiple Step Form Autocomplete Turn off autocomplete Turn off spellcheck File Upload Button Empty Input Validation
Top answer
1 of 2
1

The span elements should be completely removed and its classes placed on the image elements themselves.

Also, you have a nested section element that isn't doing anything for you.

Lastly, do not use HTML heading elements (<h1>...<h6>) because of the way they style the text. Formatting is the job of CSS. Instead of headings, it is more appropriate to surround each image and its accompanying text with figure and figcaption elements.

img { 
  width:200px;
  border:1px solid black; /* This is only added for testing purposes*/
}

.thumbnail:hover {
   width: 500px;
   height:auto;
   position:relative;
   /* push image to the right by 1/2 the screen width and 1/2 the image width */
   margin-left:calc(50% - 250px);
}
<section id="main">
  <div class="inner">
    <div class="box alt">
      <div class="row 50% uniform">
         <div class="4u">
           <figure>
             <img src="https://pbs.twimg.com/profile_images/562466745340817408/_nIu8KHX.jpeg" alt="" class="thumbnail">
             <figcaption>Marble</figcaption>
           </figure>
         </div>

         <div class="4u">
           <figure>
             <img src="http://www.critterbabies.com/wp-content/gallery/kittens/cats-animals-kittens-background-us.jpg" alt="" class="thumbnail">
             <figcaption>Marble</figcaption>
           </figure>
         </div>
         
         <div class="4u">
           <figure>
             <img src="http://www.warrenphotographic.co.uk/photography/bigs/08482-Fluffy-ginger-female-kitten.jpg" alt="" class="thumbnail">
             <figcaption>Marble</figcaption>
           </figure>
         </div>
         
       </div>
     </div>
   </div>
 </section>

2 of 2
1

I've taken Scott Marcus' answer and adapted to click, which was your original request.

The main diffence is the addition of a tags targeting elements on the page and using :target in the css.

img { 
  width:200px;
  border:1px solid black; /* This is only added for testing purposes*/
}

.thumbnail:target {
   width: 500px;
   height:auto;
   position:relative;
   /* push image to the right by 1/2 the screen width and 1/2 the image width */
   margin-left:calc(50% - 250px);
}
<section id="main">
  <div class="inner">
    <div class="box alt">
      <div class="row 50% uniform">
         <div class="4u">
           <figure>
             <a href="#image1">
             <img src="https://pbs.twimg.com/profile_images/562466745340817408/_nIu8KHX.jpeg" alt="" class="thumbnail" id="image1">
             </a>
             <figcaption>Marble</figcaption>
           </figure>
         </div>

         <div class="4u">
           <figure>
             <a href="#image2">
             <img src="http://www.critterbabies.com/wp-content/gallery/kittens/cats-animals-kittens-background-us.jpg" alt="" class="thumbnail" id="image2">
             </a>
             <figcaption>Marble</figcaption>
           </figure>
         </div>
         
         <div class="4u">
           <figure>
             <a href="#image3">
             <img src="http://www.warrenphotographic.co.uk/photography/bigs/08482-Fluffy-ginger-female-kitten.jpg" alt="" class="thumbnail" id="image3">
             </a>
             <figcaption>Marble</figcaption>
           </figure>
         </div>
         
       </div>
     </div>
   </div>
 </section>

Top answer
1 of 2
1

The span elements should be completely removed and its classes placed on the image elements themselves.

Also, you have a nested section element that isn't doing anything for you.

Lastly, do not use HTML heading elements (<h1>...<h6>) because of the way they style the text. Formatting is the job of CSS. Instead of headings, it is more appropriate to surround each image and its accompanying text with figure and figcaption elements.

img { 
  width:200px;
  border:1px solid black; /* This is only added for testing purposes*/
}

.thumbnail:hover {
   width: 500px;
   height:auto;
   position:relative;
   /* push image to the right by 1/2 the screen width and 1/2 the image width */
   margin-left:calc(50% - 250px);
}
<section id="main">
  <div class="inner">
    <div class="box alt">
      <div class="row 50% uniform">
         <div class="4u">
           <figure>
             <img src="https://pbs.twimg.com/profile_images/562466745340817408/_nIu8KHX.jpeg" alt="" class="thumbnail">
             <figcaption>Marble</figcaption>
           </figure>
         </div>

         <div class="4u">
           <figure>
             <img src="http://www.critterbabies.com/wp-content/gallery/kittens/cats-animals-kittens-background-us.jpg" alt="" class="thumbnail">
             <figcaption>Marble</figcaption>
           </figure>
         </div>
         
         <div class="4u">
           <figure>
             <img src="http://www.warrenphotographic.co.uk/photography/bigs/08482-Fluffy-ginger-female-kitten.jpg" alt="" class="thumbnail">
             <figcaption>Marble</figcaption>
           </figure>
         </div>
         
       </div>
     </div>
   </div>
 </section>

2 of 2
1

I've taken Scott Marcus' answer and adapted to click, which was your original request.

The main diffence is the addition of a tags targeting elements on the page and using :target in the css.

img { 
  width:200px;
  border:1px solid black; /* This is only added for testing purposes*/
}

.thumbnail:target {
   width: 500px;
   height:auto;
   position:relative;
   /* push image to the right by 1/2 the screen width and 1/2 the image width */
   margin-left:calc(50% - 250px);
}
<section id="main">
  <div class="inner">
    <div class="box alt">
      <div class="row 50% uniform">
         <div class="4u">
           <figure>
             <a href="#image1">
             <img src="https://pbs.twimg.com/profile_images/562466745340817408/_nIu8KHX.jpeg" alt="" class="thumbnail" id="image1">
             </a>
             <figcaption>Marble</figcaption>
           </figure>
         </div>

         <div class="4u">
           <figure>
             <a href="#image2">
             <img src="http://www.critterbabies.com/wp-content/gallery/kittens/cats-animals-kittens-background-us.jpg" alt="" class="thumbnail" id="image2">
             </a>
             <figcaption>Marble</figcaption>
           </figure>
         </div>
         
         <div class="4u">
           <figure>
             <a href="#image3">
             <img src="http://www.warrenphotographic.co.uk/photography/bigs/08482-Fluffy-ginger-female-kitten.jpg" alt="" class="thumbnail" id="image3">
             </a>
             <figcaption>Marble</figcaption>
           </figure>
         </div>
         
       </div>
     </div>
   </div>
 </section>

๐ŸŒ
W3Schools
w3schools.com โ€บ jquerymobile โ€บ tryit.asp
W3Schools online HTML editor
The W3Schools online code editor allows you to edit code and view the result in your browser
๐ŸŒ
CodePen
codepen.io โ€บ Muhnad โ€บ pen โ€บ dMbXNb
image popup
November 16, 2025 - .popup{ width: 900px; margin: auto; text-align: center } .popup img{ width: 200px; height: 200px; cursor: pointer } .show{ z-index: 999; display: none; } .show .overlay{ width: 100%; height: 100%; background: rgba(0,0,0,.66); position: absolute; top: 0; left: 0; } .show .img-show{ width: 600px; height: 400px; background: #FFF; position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%); overflow: hidden } .img-show span{ position: absolute; top: 10px; right: 10px; z-index: 99; cursor: pointer; } .img-show img{ width: 100%; height: 100%; position: absolute; top: 0; left: 0; } /*End style*/
๐ŸŒ
Bqardi
bqardi.dk โ€บ tutorials โ€บ js โ€บ image-popup โ€บ index.php
Image Popup
October 4, 2017 - But again, don't worry about it for something as simple as this image popup. thumbnails.forEach(thumbnail => { thumbnail.addEventListener("click", function(){ popupBackground.style.display = "block" //Display the popup; popupTitle.innerHTML = this.alt //Set the popup title text to the same as the thumbnails alt text; popupImage.src = this.src //Set the popup image src to the same as the thumbnail src; }) });
Find elsewhere
๐ŸŒ
W3Schools
www-db.deis.unibo.it โ€บ courses โ€บ TW โ€บ DOCS โ€บ w3schools โ€บ howto โ€บ howto_css_modal_images.asp.html
How To Create Modal Images
December 25, 2022 - // Get the modal var modal = document.getElementById('myModal'); // Get the image and insert it inside the modal - use its "alt" text as a caption var img = document.getElementById('myImg'); var modalImg = document.getElementById("img01"); var captionText = document.getElementById("caption"); img.onclick = function(){ modal.style.display = "block"; modalImg.src = this.src; modalImg.alt = this.alt; captionText.innerHTML = this.alt; } // Get the <span> element that closes the modal var span = document.getElementsByClassName("close")[0]; // When the user clicks on <span> (x), close the modal span
๐ŸŒ
insideTheDiv
insidethediv.com โ€บ onlick-popup-full-size-image-in-jquery
Click on the image to view full size in a popup modal
๐Ÿ‘‰ Create a popup modal to view a full-size image after the click. ๐Ÿ‘‰ Get and set image src from thumbnail image to modal image. ๐Ÿ‘‰ Add and remove an active class to the thumbnail image.
๐ŸŒ
W3Schools
w3schools.com โ€บ css โ€บ css3_images_modal.asp
CSS Responsive Modal Images
When a user clicks on a modal image, it shows a popup window that appears on top of the main content of the webpage, often with a semi-transparent background. The modal must be closed by the user, typically with a "close" button or an "X" sign ...
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ html โ€บ how-to-show-images-on-click-using-html
How to Show Images on Click using HTML ? - GeeksforGeeks
Example: In this example, a Bootstrap modal is triggered when clicking the "Show image" button. The modal contains an image inside the body and a "Close" button in the footer. Bootstrap and jQuery are used for functionality.
Published ย  January 10, 2025
๐ŸŒ
Willmaster
willmaster.com โ€บ library โ€บ features โ€บ image-popup.php
Image Popup
The thumbnail is an img tag in a div. The img and div tags have specific CSS properties. The div tag has an onclick attribute. Optionally, an image of a magnifying glass or other icon indicating that a larger image is available can be published over the thumbnail.
๐ŸŒ
Unc
opal.ils.unc.edu โ€บ ~lblakej โ€บ website-helps โ€บ 04-image-popup
Image Popup Example
Click image to popup the larger image with the alt text as the caption.
๐ŸŒ
W3Schools
w3schools.com โ€บ howto โ€บ tryit.asp
W3Schools Tryit Editor - Image Modal
The W3Schools online code editor allows you to edit code and view the result in your browser
๐ŸŒ
CodeWithRandom
codewithrandom.com โ€บ 2024 โ€บ 10 โ€บ 01 โ€บ create-onclick-image-popup-js
How to Create Onclick Image Popup JavaScript - CodeWithRandom
October 1, 2024 - The popup image takes a max-width of 900px and width of 100%. This is initially hidden with opacity 0 and moved up 100px using translateY(-100px) for the entrance animation. Next, .close-btn takes position absolute and some height width.
๐ŸŒ
Groupthought
help.groupthought.com โ€บ pipeline documentation โ€บ tutorials โ€บ how to show an image in a pop-up window
How to show an image in a pop-up window - Pipeline Documentation
September 27, 2018 - http://dimsemenov.com/plugins/magnific-popup/documentation.html ยท This code will make all images on your blog pages zoom into a modal window upon click.
๐ŸŒ
WowOptin
wowoptin.com โ€บ make-an-image-popup-in-wordpress
How to Make an Image Popup in WordPress [On Hover, Click & without Plugin]
June 29, 2025 - In this guide, youโ€™ll learn how to easily add WordPress image popups using a bit of code and a plugin (triggered by hover or click). If you want to keep things lightweight and avoid plugins, you can manually add an image popup using HTML, CSS, and a little JavaScript.