A photo gallery is a single web page that presents a collection of photographs as smaller thumbnail images. Selecting a thumbnail reveals a larger version, letting visitors browse several photos without leaving the page. section 10.1 section 10.2.3
Thumbnails keep the first visit lighter because full-size photos can be several megabytes each. Create a reduced copy of every image, use a consistent filename such as image01-thumbnail.jpg, and keep the matching full-size file without -thumbnail. section 10.2.3
A lightbox provides the larger view as a temporary, slightly transparent overlay. Clicking a thumbnail creates the overlay and places the full-size image in it; clicking the page removes the overlay and returns the visitor to the gallery. section 10.3
Use Flexbox for the gallery container so photo figures do not simply run down the page one by one. Centering and wrapping the content lets the image grid adapt to the browser window’s dimensions. section 10.5
A practical gallery page includes:
- A header with a logo and site title. section 10.1
- A main area with a gallery title, viewing instructions, and thumbnail figures with alt text and captions. section 10.6
- A footer with a copyright notice. section 10.1
- Separate HTML, CSS, and JavaScript files, with JavaScript handling the lightbox. section 10.6
Prompting for a gallery
Ask for HTML for the header, instructions, and every specified image figure; request CSS for colors, fonts, and Flexbox containers; then request JavaScript for a lightbox overlay. Check that the generated HTML includes every image rather than a placeholder comment, then save the files as index.html, styles.css, and script.js. section 10.6
Customize the page by editing visible text, image alt values, captions, colors, type sizes, spacing, and overlay transparency. Preserve the surrounding HTML tags, quotation marks, and px units while making those edits. For themed collections, create one gallery page at a time and add navigation between pages. section 10.8
Figure 10.1 A photo gallery generated by ChatGPT
Use the finished gallery view to identify the page’s header, main gallery, and footer before building or checking your own layout. section 10.1
