当前位置: 首页 > 图文教程 > 网页制作 > HTML/XHTML教程 > 自定义html标记替换html5新增元素

HTML/XHTML教程
网页经典代码(二)
网页经典代码(三)
网页经典代码(四)
网页经典代码(五)
网页经典代码(六)
JavaScript 中的replace方法
我有我主张!随心所欲的定制“弹出窗口”
JavaScript技术讲座-JavaScript语言概况
JavaScript技术讲座-基本数据结构
JavaScript技术讲座-程序构成
JavaScript技术讲座-基于对象的JavaScript语言
JavaScript技术讲座-创建新对象
JavaScript技术讲座-使用内部对象系统
网页加密攻略全集
防止网页内容被拷贝的方法
让JavaScript弹出窗口变得体贴一些
轻松弹出无边框网页的Javscrpt代码
强制设为首页代码
几行代码轻松搞定网页的简繁转换
打印网页时去掉页眉页脚

HTML/XHTML教程 中的 自定义html标记替换html5新增元素


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-09-11   浏览: 178 ::
收藏到网摘: n/a


在html 5增加了新元素header、footer,测试过发现IE不能解析html 5新增的元素。
代码如下:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<style type="text/css">
<!--
*{
margin:0;
padding:0;
}
header{
background:#090;
font-weight:bold;
position:absolute;
top:10px;
}
footer{
background:#f90;
font-weight:bold;
position:absolute;
bottom:10px;
}
-->
</style>
</head>
<body>
<header>这里是顶部</header>
<footer>这里是尾部</footer>
</div>
</body>
</html>

用自定义标签可以解决浏览器兼容的问题
代码如下:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns:layout>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>自定义html标签</title>
<style type="text/css">
<!--
*{
margin:0;
padding:0;
}
layout\:header{
background:#090;
font-weight:bold;
position:absolute;
top:10px;
}
layout\:footer{
background:#f90;
font-weight:bold;
position:absolute;
bottom:10px;
}
-->
</style>
</head>
<body>
<layout:header>这里是顶部</layout:header>
<layout:footer>这里是尾部</layout:footer>
</body>
</html>