This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 14733 - self-closing tag in <link rel="..." /> causes also error "end tag for head which is not close" in html 4.0
Summary: self-closing tag in <link rel="..." /> causes also error "end tag for head w...
Status: RESOLVED INVALID
Alias: None
Product: Validator
Classification: Unclassified
Component: Parser (show other bugs)
Version: HEAD
Hardware: PC Linux
: P2 blocker
Target Milestone: ---
Assignee: This bug has no owner yet - up for the taking
QA Contact: qa-dev tracking
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-11-08 20:02 UTC by matteo
Modified: 2011-11-11 21:02 UTC (History)
0 users

See Also:


Attachments

Description matteo 2011-11-08 20:02:27 UTC
Consider this code:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  <title>bla bla </title>
  <link rel="stylesheet" type="text/css" href="includes/style.css" />
  <script type="text/javascript" src="includes/jquery162.js"></script>
  <script type="text/javascript" src="includes/xxx.js"></script>
  
    <script src="http://maps.google.com/maps?file=api" type="text/javascript"></script>
    <script src="includes/general.js" type="text/javascript"></script>
  <script src="includes/qtobject.js" type="text/javascript"></script>
</head>
<!--comment-->
<body>

....


This causes the following validation errors (the first is a warning):

Line 6, Column 68: NET-enabling start-tag requires SHORTTAG YES
  <link rel="stylesheet" type="text/css" href="includes/style.css" />

 Line 13, Column 7: end tag for element "HEAD" which is not open
</head>

 Line 15, Column 6: document type does not allow element "BODY" here
<body>


The first warning is OK, but the other two errors don't make any sense. Removing the "/" in the link tag makes the errors disappear.

The use of a self closing tag ended in />  shouldn't cause these errors. Otherwise, the first warning should be an error instead of a warning.
Comment 1 Ville Skyttä 2011-11-10 20:24:35 UTC
Self-closing tags like that don't exist in SGML (HTML) in the sense they do in XML.  The / in /> closes the link tag, and the > ends up as text content.  Because text content can't exist in document head, the document body implicitly starts before >, thus the remaining (correct) errors.
Comment 2 matteo 2011-11-11 01:48:40 UTC
Then I think the warning indicating the /> should be an error instead of a warning, at least when in the head section.
Comment 3 Ville Skyttä 2011-11-11 20:24:17 UTC
It is not actually an error; it just doesn't mean what people tend to think it means so in my opinion a warning rather than an error is appropriate.
Comment 4 matteo 2011-11-11 20:34:25 UTC
but if encountered within the head, it will cause everything else to break
Comment 5 Ville Skyttä 2011-11-11 21:02:34 UTC
Not always.  For example this is a valid HTML 4.01 Transitional document:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <title>bla bla</title>
  <link rel="stylesheet" type="text/css" href="includes/style.css" />
  Hello World!