HTML可以包含两个HEAD标记 [英] Can HTML contain two HEAD tags

查看:336
本文介绍了HTML可以包含两个HEAD标记的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的web应用程序中,我得到了Header.jsp文件,其中包含默认标题内容。我在所有其他页面中使用jsp:include标签在每个单独页面的body标签内。



Header.jsp包含自己的HEAD标签以指定默认元标签,链接样式表,脚本和一些HTML元素。同时,我将在所有其他单独页面中另外设置一个HEAD标记,以定义标题,页面特定脚本和样式表。

例如:



b
$ b

Header.jsp

 < head> 
< link rel =shortcut iconhref =<%= request.getContextPath()%> /images/favicon.icotype =image / x-icon/>
< meta http-equiv =X-UA-Compatiblecontent =IE = edge/>
< script src =js / jquery.js>< / script>
< link rel = stylesheet type =text / csshref =dashboard.css>
< / head>
< h2>仪表板< / h2>

Main.jsp

 <!DOCTYPE html> 
< html>
< head>
< title>主页< / title>
< script src =main.js>< / script>
< / head>
< body>
< jsp:include page =Header.jspflush =true/>
.....
特定于主页的其他HTML内容
.....
< / body>
< / html>

是否有效?

解决方案

根据标准



相关部分:


4.2.1头元素



类别:
无。



可以使用此元素的上下文:
作为html元素中的第一个元素。


您的第二个< head> 元素不会是html文档中的第一个元素。


In my web application I got Header.jsp file which contains default header contents. Im including it in all other pages using jsp:include tag inside body tag of each individual pages.

Header.jsp contains its own HEAD tag to specify default meta tags, link stylesheets, scripts and some HTML elements. At the same time I will have another set of HEAD tag in all other individual pages to define title, page specific script and stylesheets.

For example:

Header.jsp

<head>
   <link rel="shortcut icon" href="<%=request.getContextPath()%>/images/favicon.ico" type="image/x-icon" />
   <meta http-equiv="X-UA-Compatible" content="IE=edge"/>
   <script src="js/jquery.js"></script>
   <link rel=stylesheet type="text/css" href="dashboard.css" >
</head>
<h2>Dashboard</h2>

Main.jsp

<!DOCTYPE html> 
<html>
   <head>
      <title>Main page</title>
      <script src="main.js"></script>
   </head>
   <body>
      <jsp:include page="Header.jsp" flush="true" />
      .....
      other HTML contents specific to main page
      .....
   </body>
</html>

whether it is valid to do like this?

解决方案

It's not valid according to the standard

Relevant part:

4.2.1 The head element

Categories: None.

Contexts in which this element can be used: As the first element in an html element.

Your second <head> element wouldn't be the first element in the html document.

这篇关于HTML可以包含两个HEAD标记的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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