How can we include files inside html, like how we usually include files in Php.
<?php include "nav.php";?>
How can we include files inside html, like how we usually include files in Php.
<?php include "nav.php";?>
 
    
    You can use jQuery:
HTML
<div id="container"></div>
jQuery
$("#container").load('somepage.html');
Learn more about the load function and what more you can do with it in the documentation.
 
    
    You can use Ajax, see JQuery load function, example:
<div id="moreData"></div>
$( "#moreData" ).load( "otherPage.html" );
 
    
    My suggestion would be to use jQuery.
<html> 
 <head> 
  <script src="jquery.js"></script> 
    <script> 
      $(function(){
      $("#includeCont").load("file.html"); 
      });
    </script> 
  </head> 
 <body> 
  <div id="includeCont"></div>
 </body> 
</html>
 
    
    Use ifrmae
<!DOCTYPE html>
<html>
<body>
<iframe src="http://www.w3schools.com">
  <p>Your browser does not support iframes.</p>
</iframe>
</body>
</html>
Or use Frameset
<!DOCTYPE html>
<html>
<frameset cols="25%,*,25%">
  <frame src="http://www.w3schools.com/frame_a.php">
  <frame src="http://www.w3schools.com/frame_b.php">
  <frame src="http://www.w3schools.com/frame_c.php">
</frameset>
</html>
 
    
    There is a round about method using http://httpd.apache.org/docs/current/howto/ssi.html
Server Side includes
E.g <!--#include virtual="/footer.html" --> 
 
    
    It's possible with webpack and html-webpack-plugin. This is index.html. You can create multiple files.
like this.
<%= require('html-loader!./views/partial/nav.html') %>
and here's more.
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
    <title>Your Site Title</title>
  </head>
  <body>
    <%= require('html-loader!./views/partial/nav.html') %>
    <main id="mainDiv">
      <!-- Section Banner -->
      <%= require('html-loader!./views/partial/index/section-banner.html') %>
      <!-- Section Services -->
      <%= require('html-loader!./views/partial/index/section-services.html') %>
      <!-- Section About us -->
      <%= require('html-loader!./views/partial/index/section-aboutus.html') %>
      <!-- Section Call To Action -->
      <%= require('html-loader!./views/partial/index/section-call-to-action.html') %>
      <!-- Section Footer -->
      <%= require('html-loader!./views/partial/footer.html') %>
    </main>
  </body>
</html>
