Apologies if my question is a bit confusing and poorly written, as I am new to coding and Stack Overflow. What I am trying to achieve is the ability to click on each image and have a different table pop up for each planet with facts (an example of the Mercury table is shown in the picture). I already have the table set up where I want it to appear, but I'm not sure how to link it to each image and replace it with a different table associated with the selected planet (I hope this makes sense!).
I haven't written any JavaScript code yet, but I assume I'll need a separate function for each image?
Also, how can I add space (padding, I think?) between the HTML images?
So many questions, sorry about that! 😂
h1 {
color: seagreen
}
h4 {
color: seagreen
}
table {
font-family: Arial, Helvetica, sans-serif;
border-collapse: collapse;
width: 67%;
}
td {
border: 2px solid black;
text-align: left;
font-family: Arial, Helvetica, sans-serif;
padding: 1ex
}
th {
border: 3px solid black;
text-align: center;
font-family: Arial, Helvetica, sans-serif;
padding: 1ex
}
mercury {
}
<h1>The Eight Planets</h1>
<h4> Click on any planet below to learn!</h4>
<!-- mercury -->
<img id = "mercury"
src="https://img.purch.com/w/660/aHR0cDovL3d3dy5zcGFjZS5jb20vaW1hZ2VzL2kvMDAwLzAwMy8wOTcvb3JpZ2luYWwvaWcyOTVfcGxhbmV0c19NZXJjdXJ5XzAyLmpwZw=="
width="100" height="100">
<table>
<tr>
<th> PLANET PROFILE</th>
<th>QUICK FACTS</th>
</tr>
<td> Moons: 0 </td>
<td> Your weight on Mercury would be 38% of your weight on Earth </td>
</tr>
<td> Diameter: 4,879km </td>
<td> A day on the surface of Mercury lasts 176 Earth days </td>
</tr>
<td> Orbit period: 88 days </td>
<td> Mercury has more craters and impact marks that any other planet </td>
</tr>
<td> Surface temperature: -173 to 427°C </td>
<td> After the Earth, Mercury is the second densest planet </td>
</tr>
<td> First record: 14th century BC </td>
<td> The orbit of Mercury is an ellipse rather than circular </td>
<!-- venus -->
<img id = "venus"
src="https://s-media-cache-ak0.pinimg.com/originals/98/09/66/9809666c323d35c266117428dd495791.jpg"
width="100" height="100">
<!-- earth -->
<img id = "earth" src="https://3c1703fe8d.site.internapcdn.net/newman/gfx/news/hires/2014/1-earth.jpg"
width="100" height="100">
<!-- mars -->
<img id = "mars" src="https://upload.wikimedia.org/wikipedia/commons/0/02/OSIRIS_Mars_true_color.jpg"
width="100" height="100">
<!-- jupiter -->
<img id = "jupiter" src="https://upload.wikimedia.org/wikipedia/commons/thumb/2/2b/Jupiter_and_its_shrunken_Great_Red_Spot.jpg/330px-Jupiter_and_its_shrunken_Great_Red_Spot.jpg" width="100" height="100">
<!-- saturn -->
<img id = "saturn" src="https://media.istockphoto.com/vectors/planet-saturn-vector-vector-id165060389?k=6&m=165060389&s=612x612&w=0&h=wfA9UIF6EaoGannx6fiE1gSe3G1ixtpGEfvXH2Eqhrg="
width="100" height="100">
<!-- uranus -->
<img id = "uranus" src="https://upload.wikimedia.org/wikipedia/commons/3/3d/Uranus2.jpg"
width="100" height="100">
<!-- neptune -->
<img id = "neptune" src="https://img.purch.com/h/1000/aHR0cDovL3d3dy5zcGFjZS5jb20vaW1hZ2VzL2kvMDAwLzAwMC8xMjIvb3JpZ2luYWwvMDcwOTE4X25lcHR1bmVfMDIuanBn"
width="100" height="100">
</html>