Effectively Including one html file in another html file

I have a.html file and a_style.css css file that is linked to <head>. Now I want to include a second html file, b.html , which has its own style included in the tag <style>. In particular, b.html indicates the footer I want in a.html . My question is: the a_style.css file defines headers, fields, etc., which also apply to b.html . If I include b.html in a.html , does a_style.css apply to the included file? Also, the following: I have to include b.html in a.html :

<div class="footer">
<?php include('./project/b.html');?>
</div>

is that enough? Or do I need to turn on something <head>similar to

<script type="text/javascript"
  src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
</script>

(does this specific code come from MathJax)? I do not have prior knowledge of php and found this snippet on a similar question: Insert one HTML file into another HTML file . This has not worked for me yet. I tried changing the extension to .php, but then the eclipse editor does not allow me to break apart / expand individual tags anymore, making the script very dirty.

+4
source share
2 answers

html-, php include . , PHP-. . , readfile

<div class="footer">
<?php readfile('./project/b.html');?>
</div>

, CSS/JS. <head> -Tag, <body>. , .

+1

a_style.css , .., b.html. b.html a.html, a_style.css ?

, , . , . , .

, :

  • a.php
  • a_style.css
  • b.php

: 1

a_style.css b.php a.php:

a.php

<!DOCTYPE html>
<html lang="en">
<head>
    <title>Page A</title>

    <?php

        require_once("b.php");

    ?>

    <link href="a_style.css" type="text/css" rel="stylesheet" />

</head>

<body>

    <p>This is a paragraph</p>

</body>
</html>

a_style.css

p{
    color: #00ff00; /* green */
}

b.php

<style>
    p{
        color: #0000ff; /* blue */
    }
</style>

:

enter image description here

a_style.css b.php, a_style.css ( ), , .


: 2

a_style.css, b.php a.php:

a.php

<!DOCTYPE html>
<html lang="en">
<head>
    <title>Page A</title>

    <link href="a_style.css" type="text/css" rel="stylesheet" />

    <?php

        require_once("b.php");

    ?>

</head>

<body>

    <p>This is a paragraph</p>

</body>
</html>

a_style.css

p{
    color: #00ff00; /* green */
}

b.php

<style>
    p{
        color: #0000ff; /* blue */
    }
</style>

:

enter image description here

a_style.css b.php, b.php ( ), .

+1

Source: https://habr.com/ru/post/1618354/


All Articles