How to apply same content to multiple html pages

后端 未结 4 1937
我在风中等你
我在风中等你 2020-12-06 06:34

I\'m new to html and was wondering if there is a way to apply the same content to many html files at once.

For example, if I have many pages, but all those pages hav

相关标签:
4条回答
  • 2020-12-06 07:11
    <?php
    include(file with extension);
    
    ?>
    

    You'd have to change your file extension that runs this code to DOT php

    0 讨论(0)
  • 2020-12-06 07:17

    You can write the common content in javascript file and include it in your html pages using script tag:

    <script src="YOUR_FILE.js"></script>
    

    You can use an online HTML to Javascript converter like this one to generate you javascript code.

    0 讨论(0)
  • 2020-12-06 07:21

    Server-side includes or server-side programming languages (like PHP, for example), are often used to do that. All pages just include a shared common file, which contains the common content.

    0 讨论(0)
  • 2020-12-06 07:34

    You can use PHP to do that. Write the HTML code in PHP file, then add include statement in your HTML. This saves you from having to write same code again and again specially for navigation, etc.

    PHP manual explains it.

    Hope it helps.

    0 讨论(0)
提交回复
热议问题