Would someone please explain what these error messages are telling me for this simple HTML page?
HTML Syntax Errors - Stack Overflow
How do I write error messages in HTML5?
Error within HTML Code - javascript
Videos
I went over the codes numerous times. I tried adding in and then removing the extra slash in the link tags.
What's up with this error message? Isn't my close tag correct?
<!-- Your code here -->
<!DOCTYPE html>
<html lang="en">
<head>
<title>My Site Title</title>
<link rel="stylesheet" type="text/css" href="style.css" />
</head>
<body>
</body>
</html>
Error message:
index.html
valid html
has a valid HTML structure:
AssertionError: invalid HTML:
Expected omitted end tag <link> instead of self-closing element <link/>
Trailing whitespace
: expected false to be true
expected - actual
-false
+true
at Context.<anonymous> (test/indexTest.js:103:73)
at process.processImmediate (node:internal/timers:483:21)
Your code is an absolute mess and doesn't follow the proper document structure for an HTML file, which should be:
Copy<!DOCTYPE html>
<html lang="en-us">
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
</body>
</html>
You had multiple <html> tags and tags in the wrong place with content that should not have been in them. For example, your <meta> tag was inside of your <style> element. Other issues I see: you have an <h1> and then jump to <h3>. Where's the <h2>?
So, your file would need to be re-worked to be like this (which does validate):
Copy<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Ian Morgan Kettell</title>
<style>
table {
border-style: solid;
}
td {
border-style: solid;
border-color: #FF66FF;
padding: 10px;
}
</style>
</head>
<body>
<h1>Ian's Hobbies! </h1>
<table>
<tr>
<td>Camping</td>
<td>Hiking</td>
<td>Cycling</td>
</tr>
<tr>
<td>Fishing</td>
<td>Kayaking</td>
<td>Skiing</td>
</tr>
</table>
<a href="movies.html">Learn about Ian's Favorite Actors and Movies!</a>
<h2>My Favorite Movies</h2>
<ul>
<li>Promised Land</li>
<li>Flight</li>
<li>Taken</li>
</ul>
<p>
The movies I chose were Promised Land starring Matt Damon, Flight
starring Denzel Washington, and Taken starring Liam Neeson. Even though
I have an endless list of favorite movies these are by far my top 3. I
like them because I like movies I can learn things from. For instance;
Promised Land is a film about oil companies fighting to buy land from
farmers to frack the land to find oil. It shows both sides of the
process of how they convince people and I found it extremely interesting.
</p>
<h2>My Favorite Actors</h2>
<ul>
<li>Matt Damon</li>
<li>Denzel Washington</li>
<li>Liam Neeson</li>
</ul>
<p>
If I had to choose my favorite actors my top 3 would be Matt Damon,
Denzel Washington, and Liam Neeson. I think Denzel Washington is my
favorite actor of all time. He has been an actor since the year 1981
when he made his debut apperance in the comedy A Carbon Copy.He is best
known for Philadelphia Man, Man on Fire, The Book Of Eli, American
Gangster, and Flight.In recent years he has starred in action movies.
Some of my favorite movies he's in are Inside Man, Out of Time and The
Book Of Eli, these are all kind of action dramas.
</p>
</html>
Run code snippetEdit code snippet Hide Results Copy to answer Expand
It's very easy to validate online a HTML DOM structure:
You code has the following issues:
CopyContent Occurs After End Of Body (At line 39, column 1)
Discarding Unexpected <html> (At line 40, column 2)
<meta> Lacks "content" Attribute (At line 41, column 1)
Content Occurs After End Of Body (At line 41, column 1)
<meta> Isn't Allowed In <body> Elements (At line 41, column 1)
Content Occurs After End Of Body (At line 43, column 2)
<title> Isn't Allowed In <body> Elements (At line 43, column 2)
Content Occurs After End Of Body (At line 46, column 2)
Content Occurs After End Of Body (At line 49, column 1)
Content Occurs After End Of Body (At line 60, column 1)
Content Occurs After End Of Body (At line 66, column 1)
Content Occurs After End Of Body (At line 69, column 1)
Content Occurs After End Of Body (At line 80, column 1)
Discarding Unexpected </html> (At line 86, column -3)
You can use several online HTML validator to check this like W3C Markup Validation Service or other tools like this one.
So in your specific case, you have a closing html tag on line 39, that is the first error we can see and the classic
Content Occurs After End Of Body (At line 39, column 1)
and so on.
As W3C validator points out, this first error is marked as FATAL, no way to parse the structure over:
CopyFatal Error: Cannot recover after last error. Any further errors will be ignored.
Problem with your values qty1,qty2,qty3. these values are reading as string. so instead of addding these values , its concatinating the strings. replace
var qty1 = document.getElementById("Quantity1").value;
var qty2 = document.getElementById("Quantity2").value;
var qty3 = document.getElementById("Quantity3").value;
with
var qty1 = parseInt(document.getElementById("Quantity1").value);
var qty2 = parseInt(document.getElementById("Quantity2").value);
var qty3 = parseInt(document.getElementById("Quantity3").value);
It will Solve your problem with 'Red'.
For the submit button, function total() is not returning anything. so change something like
function total() {
var p1 = document.getElementById("Price1").value; //Value is referenced to the input tag
var p2 = document.getElementById("Price2").value;
var p3 = document.getElementById("Price3").value;
var qty1 = parseInt(document.getElementById("Quantity1").value);
var qty2 = parseInt(document.getElementById("Quantity2").value);
var qty3 = parseInt(document.getElementById("Quantity3").value);
var over = qty1 + qty2 + qty3;
if (realNumber()) {
var totals = (p1 * qty1) + (p2 * qty2) + (p3 * qty3);
var yes = (totals).toFixed(2);
document.getElementById("ProductTotal").innerHTML = "$" + yes;
if (over > 30) {
document.getElementById("shipping").style.color = "red";
return true;
} else if(over>0) {
document.getElementById("shipping").style.color = "black";
return true;
}else{
document.getElementById("shipping").style.color = "black";
return false;
}
}
}
and checkout() as
function checkOut() {
if (total()) {
if (((document.getElementById("shipping").style.color == "red") &&
(document.getElementById("extra").checked))||
(document.getElementById("shipping").style.color != "red")) {
return true;
}
}
return false;
}
Replace
var over = qty1 + qty2 + qty3;
With
var over = parseInt(qty1) + parseInt(qty2) + parseInt(qty3);