Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to separate html text file into multiple files?

Tags:

html

css

Very basic question about html.

Because the <body> is too long, I want to divide the file into multiple files. It is not about using iframe etc, but just want to include multiple text files to create <body> of the html file.

Thank you!

like image 899
eng27 Avatar asked Dec 12 '15 09:12

eng27


People also ask

Can you split HTML into multiple files?

You can have multiple instances of the HTML Help ActiveX control in a single HTML file to split the file in multiple locations. This feature can be used only with a compiled help (. chm) file.

How do you separate text in HTML?

<br>: The Line Break element. The <br> HTML element produces a line break in text (carriage-return). It is useful for writing a poem or an address, where the division of lines is significant.

How do you separate pages in HTML?

In HTML, we can divide a whole webpage into sections by using <div> tag along with the CSS. By default, a <div> tag divides a webpage into horizontal sections. However, you can use the float property of CSS to make the vertical sections of the webpage.


2 Answers

You can do it using jQuery:

<head> 
    <script src="jquery.js"></script> 
    <script> 
        $(function(){
            $("#ContentToInclude").load("b.txt or b.html"); 
        });
    </script> 
</head>

And load it in HTML:

<body> 
   <div id="ContentToInclude"></div>
</body>
like image 58
Nitesh Pogul Avatar answered Oct 25 '22 06:10

Nitesh Pogul


Just change the extension to .php instead of .html. Then you can just put, for example, your whole head inside the file head.php( or head.inc).

The whole thing would look something like this then:

<!DOCTYPE html>

<?php
  include 'head.php';
?>

<body>
 <!-- stuff in here -->
</body>

<html>

You can obviously split your body up into seperate pieces like this:

<body>

<?php
  include 'firstPart.php';
?>

<!-- some other stuff -->

</body>
like image 43
Tobias Glaus Avatar answered Oct 25 '22 04:10

Tobias Glaus