Hello,
Please take a look at the attached image. How can I create this without using a table?
I tried dl and ol. But I can't get the elements to sit next to each other. Please advise.
Hello,
Please take a look at the attached image. How can I create this without using a table?
I tried dl and ol. But I can't get the elements to sit next to each other. Please advise.
A compact, robust way to do this is to pair semantic HTML (a list or <figure>/<figcaption> for each item) with modern CSS layout — Flexbox or Grid — instead of fixed-height wrappers and floats. ’s float idea works but tends to need extra clearing and fixed heights; ’s suggestion of a list is the right semantic direction; is correct to push styles into a stylesheet. Below is a practical, different approach you can apply immediately.
HTML (semantic gallery structure)
<ul class="gallery">
<li>
<figure>
<img src="thumb1.jpg" alt="Short description">
<figcaption>Caption or title</figcaption>
</figure>
</li>
<!-- repeat items -->
</ul> CSS (Flexbox, responsive columns)
.gallery {
display: flex;
flex-wrap: wrap;
margin: 0;
padding: 0;
list-style: none;
}
.gallery li {
flex: 1 0 25%; /* 4 columns, shrinks/grows */
box-sizing: border-box;
padding: 8px;
}
.gallery img {
display: block;
width: 100%;
height: auto;
} If you want more control over breakpoints and equal gaps, use CSS Grid instead (e.g., grid-template-columns: repeat(auto-fill, minmax(200px, 1fr))). Practical tips: give images width/height attributes or use object-fit to avoid layout shift; use box-sizing: border-box; avoid fixed container heights; test older browsers (fallback to floats if IE9 support is required). For details and examples see and CSS Grid.
Jump to Post— colweb 13I would do something like this. Inside a container div with a fixed height, you place floating divs with the images and description. Because the divs are floating the will go left to right. The containers will go top to bottom.
And instead of embedding the style this way (but …
Jump to Post— colweb 13<!-- style out in the external stylesheet usually -->
.con {height:300px;width100%;} .in {width:25%;height:100%;float:left;<div class='con'> <div class='in'><img src="image1"><br>description 1</div> <div class='in'><img src="image2"><br>description 2</div> <div class='in'><img src="image3"><br>description 3</div> <div class='in'><img src="image4"><br>description 4</div> </div> <div class='con'> <div class='in'><img src="image5"><br>description 5</div> <div class='in'><img src="image6"><br>description 6</div> <div class='in'><img src="image7"><br>description 7</div> …
Jump to Post— almostbob 866My apologies, I did not read,
nor can I see anything that says
"look at what the ** did, this is a personal attack"
you could have accepted that someone else thinks the same way you do
or you could
traho vestri caput capitis ex vestri rectum
I would do something like this. Inside a container div with a fixed height, you place floating divs with the images and description. Because the divs are floating the will go left to right. The containers will go top to bottom.
And instead of embedding the style this way (but I only do it do demonstrate the principle), you could make the container(s) and floating divs a class and style them from css.
<div style="height:300px"> <!-- the container -->
<div style="float:left;"><img src="image1"><br>description 1</div>
<div style="float:left;"><img src="image2"><br>description 2</div>
<div style="float:left;"><img src="image3"><br>description 3</div>
<div style="float:left;"><img src="image4"><br>description 4</div>
</div> <!-- end containter -->
<div style="height:300px"> <!-- the container -->
<div style="float:left;"><img src="image5"><br>description 5</div>
<div style="float:left;"><img src="image6"><br>description 6</div>
<div style="float:left;"><img src="image7"><br>description 7</div>
<div style="float:left;"><img src="image8"><br>description 8</div>
</div> <!-- end containter --> I would do something like this. Inside a container div with a fixed height, you place floating divs with the images and description. Because the divs are floating the will go left to right. The containers will go top to bottom.
And instead of embedding the style this way (but I only do it do demonstrate the principle), you could make the container(s) and floating divs a class and style them from css.<div style="height:300px"> <!-- the container --> <div style="float:left;"><img src="image1"><br>description 1</div> <div style="float:left;"><img src="image2"><br>description 2</div> <div style="float:left;"><img src="image3"><br>description 3</div> <div style="float:left;"><img src="image4"><br>description 4</div> </div> <!-- end containter --> <div style="height:300px"> <!-- the container --> <div style="float:left;"><img src="image5"><br>description 5</div> <div style="float:left;"><img src="image6"><br>description 6</div> <div style="float:left;"><img src="image7"><br>description 7</div> <div style="float:left;"><img src="image8"><br>description 8</div> </div> <!-- end containter -->
Thank you I'll try it.
<!-- style out in the external stylesheet usually -->
.con {height:300px;width100%;}
.in {width:25%;height:100%;float:left; <div class='con'>
<div class='in'><img src="image1"><br>description 1</div>
<div class='in'><img src="image2"><br>description 2</div>
<div class='in'><img src="image3"><br>description 3</div>
<div class='in'><img src="image4"><br>description 4</div>
</div>
<div class='con'>
<div class='in'><img src="image5"><br>description 5</div>
<div class='in'><img src="image6"><br>description 6</div>
<div class='in'><img src="image7"><br>description 7</div>
<div class='in'><img src="image8"><br>description 8</div>
</div> <!-- style out in the external stylesheet usually -->
.con {height:300px;width100%;} .in {width:25%;height:100%;float:left;<div class='con'> <div class='in'><img src="image1"><br>description 1</div> <div class='in'><img src="image2"><br>description 2</div> <div class='in'><img src="image3"><br>description 3</div> <div class='in'><img src="image4"><br>description 4</div> </div> <div class='con'> <div class='in'><img src="image5"><br>description 5</div> <div class='in'><img src="image6"><br>description 6</div> <div class='in'><img src="image7"><br>description 7</div> <div class='in'><img src="image8"><br>description 8</div> </div>
If you can read, I did write
And instead of embedding the style this way (but I only do it do demonstrate the principle), you could make the container(s) and floating divs a class and style them from css.
My apologies, I did not read,
nor can I see anything that says
"look at what the ** did, this is a personal attack"
you could have accepted that someone else thinks the same way you do
or you could
traho vestri caput capitis ex vestri rectum
Using that many <div> tags is a very amateur way of coding something like that. I would use <ul>, something like this :
<ul id="whatever">
<li>stuff here</li>
<li>stuff here</li>
<li>stuff here</li>
<li>stuff here</li>
<li>stuff here</li>
<li>stuff here</li>
<li>stuff here</li>
<li>stuff here</li> (x8 times)
</ul>
...and for the styling something like :
#whatever li {
float:left;
width:25%; (or a quarter of the total width)
}
=D
Using that many <div> tags is a very amateur way of coding something like that.
:icon_biggrin:Then most of the web is must be written by amateurs :icon_cheesygrin: Or maybe its only the sites I visited.:icon_biggrin:
Personally I find divs easier to work with and ryy705 had tried to use <dl> and <ol> but couldn't make that work. So the first thing that came to my mind "do it with divs". But must agree that your method works perfectly also.
this thread parallels web design,,
wants
works
works better, solved
:icon_biggrin:Then most of the web is must be written by amateurs :icon_cheesygrin: Or maybe its only the sites I visited.:icon_biggrin:.
Yes it is :p
Theres no harm in using so many <div> tags, it's just not optimised (i have a sad obsession with optimisation)
this thread parallels web design,,
wants
works
works better, solved
Lol definitely.
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.