My goal is to dynamically generate <li>
elements from a CSS file, as opposed to manually defining them in the HTML.
Purpose/Goal:
I have multiple HTML files, each containing a menu structured using LIST items (<li>
).
Instead of adding each item individually to every HTML file, I would like to populate the list items using my CSS file. This way, if I need to add a new <li>
in the future, I can do so without having to edit each HTML file separately. By simply adding one list item in the CSS file, it will automatically appear in all lists across my HTML files.
---CURRENT HTML CODE:
<div id="menu">
<ul>
<li><a href="../index.html">Home</a> </li>
<li><a href="../about-us.html">About us</a> </li>
</ul>
</div>
I am aiming to have <li>
and <a>
elements generated from CSS rather than hardcoded into the HTML file.