So for specific reasons I'm trying to use the dl (Description List) html element. I wanted the elements contents to display each dt
and dd
on their own row which I accomplished as such..
div {
padding: 1rem;
color: #fff;
background-color: rgba(0,0,0,.8);
}
dl dt, dl dd {
display: inline;
line-height: 1.75rem;
}
<div>
<h3>Cryptids of Cornwall:</h3>
<dl>
<dt>Beast of Bodmin</dt>
<dd>A large feline inhabiting Bodmin Moor.<br></dd>
<dt>Morgawr</dt>
<dd>A sea serpent.<br></dd>
<dt>Owlman</dt>
<dd>A giant owl-like creature.<br></dd>
</dl>
</div>
Which is really close to what I'm after, but I'm wondering if anyone knows a way with maybe Flex or Grid for a more uniformed layout like a table while still using the dl
the element so the output is more like this...
table {
border-collapse: collapse;
color: #fff;
background-color: rgba(0,0,0,.8);
}
table th {
text-align: left;
padding-left: 1rem;
}
table td {
padding: 1rem;
}
table tr td:first-of-type {
text-align: right;
border-right: lightgray 1px solid;
}
<table>
<tr>
<th colspan="2">
<h3>Cryptids of Cornwall:</h3>
</th>
</tr>
<tr>
<td>Beast of Bodmin</td>
<td>A large feline inhabiting Bodmin Moor.</td>
</tr>
<tr>
<td>Morgawr</td>
<td>A sea serpent.</td>
</tr>
<tr>
<td>Owlman</td>
<td>A giant owl-like creature.</td>
</tr>
</table>
Is there a way to accomplish this with css and explicitly using the dl
element? I've tried things display: table
on the parent dl
with the dt
and dd
as display: table-cell
but then I can't seem to break the into new rows after the dd
along with failed attempts at using flex and css grid so wondering if someone knows a trick to teach? Thanks!
` elements things won't break.
– Dai Apr 13 '22 at 03:55