r/HTML • • 18d ago

Question Wikipedia style gallery

Hello, I'm new to HTML and CSS, I would like to replicate the wiki-style gallery at the bottom of a section when showcasing relevant images/info grouped together, but I have not figured it out yet.

Here's an example of what I'm talking about: https://en.wikipedia.org/wiki/Animal#Evolutionary_origin

I am guessing it's something about container ID? My previous attempts were me trying to work with the container styles in the CSS. Though I gave up and didn't save my failed attempt (wrong of me, I know)
Could I get help on how to replicate replicate it?

Thank you for the help in advance.

4 Upvotes

3 comments sorted by

1

u/armahillo Expert 18d ago

can you post your attempts in a codepen / jsfiddle instance so we can see what you’re doing?

i know you know what you’ve tried already but we don’t

1

u/JeLuF 18d ago

I am guessing it's something about container ID?

No, the IDs are only used for links. The layout is entirely driven by the classes.

There's an <ul> as outer container, each card is a <li> which contains two <div>s, one for the thumbnail image, one for the text. The <li> get's an attribute display: inline-block so that the cards automatically wrap into multiple lines.

This code is old-fashioned, and today, I'd use a CSS flexbox or a CSS grid instead. They didn't exist back in the days. w3schools has an example of how to do this today: https://www.w3schools.com/css/css_image_gallery.asp