I’m learing tables on html right now and I’m working on a periodic table for my first school project. I’m having trouble formatting the text. I expect the atomic number and mass to be on the same line, but the atomic number on the left and the mass on the right, but I don’t know what tag to use (I’m using div).
This is what I’ve tried:
<th class= hidrogenio>
<div class= numeroatomico>
1
<div class= massa>1,008</div>
</div>
H
<div class= nome>Hidrogênio</div>
</th>
2
Answers
You can use flexbox to achieve this:
Creating a periodic table in HTML and CSS is a difficult assignment for someone who is just learning tables. The solution requires nested tables: an outer table to manage the periodic table itself, and within each cell of the outer table is an inner (nested) table to manage the layout of the element.
The inner tables require three rows and two columns. The second and third rows each contain a cell which spans both columns.
Then you need an outer table to manage the entire thing. Here’s a start: