sureshd sureshd - 7 months ago 63
HTML Question

Can HTML contain two HEAD tags

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:


<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" >


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

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.