@xaintobas
Posted
Hi @steveostler,
Nice work on your design!
I reviewed the original code and your implementation for aligning the nutritional information. I noticed that you struggled with getting the information to align correctly. Your current approach using an unordered list with spans is functional, but aligning elements within a list can sometimes be challenging. I have a few suggestions that might help:
I recommend using a table for this type of information. Tables are inherently better for displaying data that needs to be aligned in rows and columns.
<table>
<tr class="td__row">
<td class="td__name">Calories</td>
<td class="td__value">277kcal</td>
</tr>
<tr class="td__row">
<td class="td__name">Carbs</td>
<td class="td__value">0g</td>
</tr>
<tr class="td__row">
<td class="td__name">Protein</td>
<td class="td__value">20g</td>
</tr>
<tr class="td__row">
<td class="td__name">Fat</td>
<td class="td__value">22g</td>
</tr>
</table>
table {
width: 100%;
}
td {
padding: 1rem 1rem 1rem 2.5rem;
border-bottom: 1px solid grey; /* You can change the color */
}
.td__value {
font-weight: 700;
color: grey; /* You can change the color */
}
Benefits of Using a Table: -Tables provide a straightforward way to align data in rows and columns. -Tables can be more accessible to screen readers and other assistive technologies when used correctly. -It's easier to style rows and columns using CSS with tables.
I hope you find my feedback valuable and helpful.
If yes, I would appreciate it greatly if you could mark my comment as helpful!
Happy coding 😊
Marked as helpful
@steveostler
Posted
Thanks for your suggestion @xaintobas I originally set out to use table tags but changed my mind. I can see how table would be better