I'm working on a required static page assignment. (not my choice)
I have a navigation that I'd like to be available for dozens of static html files.
I'm getting the markup via jQuery/javascript
$(function () {
// get navigation menu
$.get('nav.html', function (data) {
$('.navigation').replaceWith(data);
});
});
Things start to get funky here
The markup I'm loading into multiple pages are as such:
I'm adding no body
tag since the idea is that this content will be loaded into existing HTML pages.
nav.html
<ul>
<li><a href="">Home</a></li>
<li><a href="">News</a></li>
<li><a href="">Contact</a></li>
<li><a href="">About</a></li>
</ul>
My problem is that none of the styles applied to nav.html
were loaded.
Then in order to get the css styles into nav.html
I added a head
tag which smells like a very bad practice and is where I'm seeking guidance here.
nav.html (with head tag)
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" href="xlib/bootstrap/bootstrap.min.css" />
<link rel="stylesheet" type="text/css" href="app.css" />
<link rel="stylesheet" type="text/css" href="nav.css" />
</head>
<ul>
<li><a href="">Home</a></li>
<li><a href="">News</a></li>
<li><a href="">Contact</a></li>
<li><a href="">About</a></li>
</ul>
What is the best practice to load same HTML markup into multiple pages, while doing so asynchronously and getting all the needed styles for the same HTML markup.?