Coding · Websites

Add a Photo Gallery to Your Web Page

Show your pictures in a neat grid that opens bigger when clicked, using simple code you can paste in.

Prompt Code output

I want a photo gallery on my web page. I have about [NUMBER_OF_PHOTOS] photos of [PHOTO_TOPIC]. When someone clicks a photo it should open larger on top of the page, with arrows to go to the next one and a way to close it. Please write this with plain HTML, CSS and a small amount of JavaScript, with no extra libraries to install. Make the grid adjust to phone screens. Keep the code short and add comments explaining what each part does in everyday words. Tell me where to paste each part in my page, how to name and store my photo files, and how to add or remove a photo later. My page is built with: [SITE_BUILDER].

Fill in the brackets

[NUMBER_OF_PHOTOS]
e.g. 12
[PHOTO_TOPIC]
e.g. finished kitchen renovations, our restaurant dishes
[SITE_BUILDER]
e.g. a plain HTML file, or a page builder that lets me add custom code

How to use

  1. Copy the prompt.
  2. Replace the text inside [BRACKETS] with your own details.
  3. Paste it into ChatGPT or another AI assistant.
  4. Read the result and ask for changes if needed.

Tip: Shrink large photos before uploading so the gallery loads quickly on phones.