I’m trying to figure out errors #5 & #6 stated here: https://validator.w3.org/nu/?showsource=yes&doc=http%3A%2F%2Fwww.criminal-lawyers.com.au#l213c125
This is a heavily abbreviated excerpt from the HTML page (indented and with some annotations added):
<!DOCTYPE html>
<html lang="en-US" prefix="og: http://ogp.me/ns#">
<head>
<meta name="google-site-verification" content="hC6haEDgNzt-f1TAXuv9CrzeH2K5caXUbr-b1XSXcUo" />
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<title>Criminal Lawyers Melbourne - Doogue O'Brien George</title>
<!-- Omitted huge number of <meta>, <link>, <style> and <script> elements -->
<style type="text/css" id="custom-background-css">
body.custom-background { background-color: #dddddd; }
</style>
<span style="display:none">SCS URL: http://www.criminal-lawyers.com.au<br>Page Id: 5150<br></span>
<link href="https://plus.google.com/100949400750888670994" rel="publisher"/>
<script type="text/javascript"> /* Omitted */ </script>
</head> <!-- Line 211 -->
<body onload="_googWcmGet('number', '03-9670-5111')" class="home page page-id-5150 page-template-default custom-background ">
<!-- Omitted -->
</body>
</html>
Error messages from the Validator:
-
Error: Stray end tag
head
.From line 211, column 1; to line 211, column 7
</script>â©</head>â©â©<bod
-
Error: Start tag
body
seen but an element of the same type was already open.From line 213, column 1; to line 213, column 125
â©</head>â©â©<body onload="_googWcmGet('number', '03-9670-5111')" class="home page page-id-5150 page-template-default custom-background ">â© â© <d
But seriously, I don’t think the errors pointed out actually exist. How come the closing head tag is stray and that there’s another body element open? Whenever I check the source code, there’s only one closing head tag and there’s really only one open body tag. Where are these errors?
Will appreciate any feedback.
UPDATED July 3, 2015:
The span element as shown when checking the source code is not exactly like that at the back end. It is controlled by another set of codes:
<span style="display:none">
<?php
global $wp;
$current_url = home_url(add_query_arg(array(),$wp->request));
echo "SCS URL: ".$current_url."<br>";
$page_id = get_the_ID();
echo "Page Id: ".$page_id."<br>";
if($page_id == 5133){
?>
<script>
//document.title = "Lawyers Profile | Criminal Lawyers Melbourne - Doogue O'Brien George";
</script>
<?php
//echo "it's the page";
}else{
//echo "it's not the page";
}
?>
</span>
The above is what’s actually on the back end. I tried transferring this to the body and also tried simply deleting it. Both ways resulted to further errors.
Okay, I think it’s wrong to assume that the further errors were due to the fix. As mentioned by one of the commenters below, by fixing one error, you enable the validator to find other errors.
In HTML, the
HEAD
andBODY
(andHTML
) elements are always present*. The tags that mark the start and end of the elements, however, are optional. The HTML parser will insert the open and closing tags as needed depending on what markup the document contains.When it encounters the
<span>
, which is not allowed inside theHEAD
element, it implicitly closes theHEAD
and opens theBODY
element as if there was a</head>
and a<body>
tag present.Later, the parser comes across the
</head>
tag for aHEAD
element that is already closed, and a<body>
tag which attempts to open anotherBODY
element.Just remove the
SPAN
, move it into theBODY
element or work the contents into theTITLE
or similar.*HTML4 frameset documents must have a
FRAMESET
element instead of aBODY
.The issue is that you have a
<span>
element in<head>
this is not valid.Get rid of this and your problem is resolved.