在每个页面上包含页眉/页脚? [英] Including header/footer on every page?

查看:109
本文介绍了在每个页面上包含页眉/页脚?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我的第一个问题是,如何包含我的导航栏,标题和脚注在所有的HTML文件,而不是复制每个人的完整代码?
我的第二个问题是,html结构应该如何在单独的页眉/页脚文件中查找,这样我可以将它们包含在我的页面html中?



如果您提到PHP作为一个解决方案,请指出我的过程的一些链接/教程。

解决方案

如果您使用php文件,您可以这样做:

index.php:

 <? 
include(header.php);
?>

//页面内容

<?
include(footer.php)
?>

header.php:

 < HEAD> 
// head
< / head>
< body>

footer.php:

 <页脚> 
//页脚
< /页脚>
< / body>

在header.php中,您可以放置​​标签等。
在每个页面中,您都可以只需包含这些文件而不是

I'm making a website with multiple pages with About info, Projects, Events etc.

My first question is, how can I include my nav bar, header and footer to be in all of the html files without copying the full code for each of them? My second question is, how should the html structure look in the separate header/footer files so I can include them in my pages html's?

If you mention PHP as a solution, please point me to some link/tutorial for the process.

解决方案

If you use php files you could do something like this:

index.php:

<? 
    include("header.php");
?>

    //page content

<?
    include("footer.php")
?>

header.php:

<head>
    //head
</head>
<body>

footer.php:

<footer>
    //footer
</footer>
</body>

In the header.php you could put the tags etc. In every page you could just include these files than

这篇关于在每个页面上包含页眉/页脚?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆