Edit: I've found 2 questions that have already been asked (much more concisely) that have answers for this question, so this can be locked or deleted.
Including external HTML file to another HTML file [duplicate]
Best practice to create a template in HTML [closed]
I apologize in advance because I'm not sure the proper terminology to search for this answer, I only have intermediate knowledge of HTML and CSS, and I'm only barely familiar with JS. I can't write it yet, but if I need to download a simple library and call up something to do this, that shouldn't be much of a problem.
In this example we assume the HTML files share a directory.
The files are the parent section.html
, and the children files I'd need to pull contents from: cylinder.html
, prism.html
, and sphere.html
.
This is section.html
:
<div class='container'>
<div class='card'>
Lorem ipsum dolor sit amet, consectetur adipisicing elit
</div>
<div class='card'>
<!-- display contents of cylinder.html, prism.html, or sphere.html here -->
</div>
</div>
I'm looking for a simple way to insert the contents of one of those three files into the second nested div (third overall) in section.html
that would display the contents of whichever of those files I inserted.
For instance, if this is cylinder.html
:
<table id='cylinders'>
<tbody>
<caption>Cylinders</caption>
<tr>
<th>Height</th>
<th>Circumference</th>
<th>Weight</th>
</tr>
<tr>
<td>1m</td>
<td>40cm</td>
<td>55kg</td>
</tr>
<tr>
<td>1.2m</td>
<td>50cm</td>
<td>83kg</td>
</tr>
</tbody>
</table>
So that when section.html
is read by a browser, it sees this:
<div class='container'>
<div class='card'>
Lorem ipsum dolor sit amet, consectetur adipisicing elit
</div>
<div class='card'>
<table id='cylinders'>
<tbody>
<caption>Cylinders</caption>
<tr>
<th>Height</th>
<th>Circumference</th>
<th>Weight</th>
</tr>
<tr>
<td>1m</td>
<td>40cm</td>
<td>55kg</td>
</tr>
<tr>
<td>1.2m</td>
<td>50cm</td>
<td>83kg</td>
</tr>
</tbody>
</table>
</div>
</div>
(I don't want to share too much irrelevant information here, but my reasoning for this is that I'm building a simple but large shopify store as a project, and I'd like to have a way to update/modify particular parts of many product descriptions at once without having to go through and edit them one by one. This way I can update cylinder.html
down the line if I change the size or measurements of a particular set of products. )