How to make same layout for all web pages

后端 未结 5 1219
野趣味
野趣味 2021-01-02 13:22

I am currently working on HTML I want to ask a question about website development.I am developing a website in which the basic layout remains same like menu, side menu etc b

相关标签:
5条回答
  • 2021-01-02 13:58

    Your best bet in the long term is to use a server side language like ASP.net or PHP

    0 讨论(0)
  • 2021-01-02 14:00

    Yes, your best bet is a server side language, as Adam said. Absolutely avoid using the old style html frames: they're deprecated, and cause a certain number of problems, both on the programming side and on google optimization.

    By using a server side language, you'll still have entire pages, but they will be partially generated by php (or asp) by printing more files into one. For example:

    http://www.php.net/manual/en/function.include.php

    Bye!

    0 讨论(0)
  • 2021-01-02 14:07

    If your HTTP (apache 2 and IIS do) server supports Server Side Includes then you can just include another HTML file :

    <!--#include file="header.html"-->
    
    your content
    
    <!--#include file="footer.html"-->
    

    no need for a server side language then - just plain HTML

    0 讨论(0)
  • 2021-01-02 14:07

    This is very big topic to include in just one answer. SO I will give only the logical part.

    Separate your template into multiple chunks like:

    1. header.php
    2. leftSidebar.php
    4. rightsidebar.php
    5. footer.php
    

    Now, include these common part on your every page.

    For example: index.php

    <?php
    
        include "header.php";
        include "leftSidebar.php";
        echo "<div>".$thedifferentpart."</div>"; //Change only this part on every other page you will create.
        include "footer.php";
    
    ?>
    

    NOTE: This is only a logical part, applying the concept on your code

    0 讨论(0)
  • 2021-01-02 14:20

    I don't believe that is possible, strictly through HTML. However, you could use server side scripting like PHP to get it done. What you're talking about is a template, and is used quite often. What you would want, is to have your menu items (and CSS) and your header/footer code in separate pages. This way, if you make changes to the menu, or header/footer, it would be reflected in all the pages (written with PHP) you have scripted with the template method.

    You would need the menu.html, header.html and footer.html in a place accessible by your main page code. That is, you would use the template method to write the content of your pages.

    A psuedo code example in PHP would be like such:

    <?php
       include('header.html');
       include('menu.html');
    
        echo "Your main content items here";
    
       include('footer.html');
    ?>
    
    0 讨论(0)
提交回复
热议问题