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;

}
Answer from Sabith on Stack Overflow
🌐
W3Schools
w3schools.com › js › js_errors.asp
JavaScript Error Statements
JS Examples JS HTML DOM JS HTML ... ... In JavaScript, the try statement is used to handle errors (also called exceptions) that may occur during code execution - without stopping the entire program....
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Errors
JavaScript error reference - JavaScript | MDN
July 8, 2025 - SyntaxError: use of super property/member accesses only valid within methods or eval code within methods · SyntaxError: Using //@ to indicate sourceURL pragmas is deprecated.
Discussions

Would someone please explain what these error messages are telling me for this simple HTML page?
It sounds like you might have a syntax issue or a misplaced tag, double-check your HTML structure. More on reddit.com
🌐 r/learnprogramming
6
1
July 30, 2024
jquery - Javascript unexpected token ] error inside HTML code, how can it be possible? - Stack Overflow
I get this javascript error in Chrome's console Unexpected token ] pointing to the middle of raw HTML code, what can it be? Unfortunately I can't post the whole code, but the only javascript present More on stackoverflow.com
🌐 stackoverflow.com
January 23, 2015
HTML Syntax Errors - Stack Overflow
Also, you have TWO 's but no begin tag. ... @ArleighHix "In-page" navigation is not done by pushing content way down the page. That's not a "thing" - that's a hack. Something like what you are showing would be done with JavaScript and CSS's display property. ... Save this answer. Show activity on this post. Your code ... More on stackoverflow.com
🌐 stackoverflow.com
javascript - How can I enable Visual Studio Code HTML error checking and validation? - Stack Overflow
I would have thought error checking to be a fundamental function in a web development editor like Visual Studio Code. Maybe I am just not finding the right option or extension. How can I achieve this same HTML, CSS error checking behaviour in Visual Studio Code? More on stackoverflow.com
🌐 stackoverflow.com
Top answer
1 of 3
5

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;

}
2 of 3
2

Replace

var over = qty1 + qty2 + qty3;

With

var over = parseInt(qty1) + parseInt(qty2) + parseInt(qty3);
🌐
Reddit
reddit.com › r/learnprogramming › would someone please explain what these error messages are telling me for this simple html page?
r/learnprogramming on Reddit: Would someone please explain what these error messages are telling me for this simple HTML page?
July 30, 2024 -

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:

  1. 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)

🌐
Dummies
dummies.com › article › technology › programming-web-design › html5 › how-to-resolve-javascript-syntax-errors-for-html5-and-css3-programming-156957
How to Resolve JavaScript Syntax Errors for HTML5 and CSS3 Programming | dummies
July 2, 2025 - The most common type of JavaScript error in HTML5 is a crash or syntax error, usually meaning you misspelled a command or used a function incorrectly. From the user's point of view, browsers don't usually tell you directly when a syntax error ...
🌐
IU Knowledge Base
kb.iu.edu › d › bfrc
Common HTML error codes
September 8, 2021 - Loading · Skip to page content
🌐
Medium
medium.com › @wewillcode › top-12-common-errors-that-you-encounter-while-using-html-f2909e3b1d48
TOP 12 COMMON ERRORS THAT YOU ENCOUNTER WHILE USING HTML | by Harsh Mehta | Medium
September 27, 2020 - HTML standards require that you identify the type of scripting language that is being used. Most scripts include the language attribute. This alone is not enough, you must also include a type attribute. In fact, in the future, the language attribute will be replaced with the type attribute. ... Any JavaScript that performs a function or outputs information must have a <noscript> tag that provides an alternative or explanation for what the JavaScript does.
Find elsewhere
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Learn › HTML › Introduction_to_HTML › Debugging_HTML
Debugging HTML - Learn web development | MDN
July 26, 2024 - At the time of writing, it said "Document checking completed. No errors or warnings to show." So there we have it, an introduction to debugging HTML, which should give you some useful skills to count on when debugging HTML, but also CSS and JavaScript code later on in the course.
Top answer
1 of 5
3

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

2 of 5
1

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.
Top answer
1 of 6
92

Visual Studio Code doesn't have HTML validation by default. But it allows you to add extensions and enable these features.

To add HTML validation (linting), open Visual Studio Code, and then press Ctrl + P. Then paste ext install HTMLHint in it, and press Enter. It will install an HTML validator. You may need to reload Visual Studio Code to load the extension.

Now if you open the same HTML document you had the syntax error in, you should see there's an issue shown at the status bar at the bottom :), and it will also show you the errors in those lines.

2 of 6
9

Visual Studio Code by default supports code formatting and it tracks the syntactical errors. If you create a new file and directly try to write the code then Visual Studio Code would not be able to understand which language or type of syntax the user wants to format or correct.

So, one first needs to save the new file with the proper extension, and then Visual Studio Code can properly identify the syntax.

The code formatting is available in Visual Studio Code through the following shortcuts:

  • On Windows Shift + Alt + F
  • On Mac Shift + Option + F
  • On Ubuntu Ctrl + Shift + I

You can add Auto Close Tag from the Visual Studio Code marketplace.

Launch Visual Studio Code Quick Open (Ctrl + P), paste the following command, and press Enter.

  1. Automatically add the HTML/XML close tag, the same as Visual Studio IDE or Sublime Text

    ext install auto-close-tag
    
  2. Visual Studio Code integration for HTMLHint - A Static Code Analysis Tool for HTML

    ext install HTMLHint
    
  3. Provides CSS class name completion for the HTML class attribute based on the CSS files in your workspace. It also supports React's className attribute.

    ext install html-css-class-completion
    
🌐
CodeBasics
code-basics.com › frontend › html course › errors in html markup
Errors in HTML markup | HTML | CodeBasics
[HTML] — Errors in HTML markup — When marking up content on the page, there can often be problems, e.g., forgetting to close the tag, nesting elements that cannot be nested, or forgetting to specify the required tags...
🌐
Kinsta®
kinsta.com › home › resource center › blog › javascript errors › a definitive guide to handling errors in javascript
A Definitive Guide to Handling Errors in JavaScript
June 19, 2023 - Without any of those, the interpreter will raise a SyntaxError. Therefore, make sure to follow your try blocks with at least either of them when handling errors. The onerror() method is available to all HTML elements for ...
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Learn_web_development › Core › Scripting › Debugging_JavaScript
JavaScript debugging and error handling - Learn web development | MDN
February 12, 2026 - If you get stuck, you can find the fixed source code at https://github.com/mdn/learning-area/tree/main/tools-testing/cross-browser-testing/javascript/fetch-fixed. Note: The debugger tab has many other useful features that are not discussed here. For example, conditional breakpoints and watch expressions. For a lot more information, see the Debugger page. HTML and CSS are permissive — errors ...
🌐
W3Schools
w3schools.com › tags › ref_httpmessages.asp
W3Schools.com
When a browser requests a service from a web server, an error might occur, and the server might return an error code like "404 Not Found". It is common to name these errors HTML error messages.
🌐
W3Schools
w3schools.com › js › js_errors_intro.asp
JavaScript Errors Try Catch Throw
Newer versions of JavaScript do not throw EvalError. Use SyntaxError instead. ... If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail: sales@w3schools.com · If you want to report an error, or if you want to make a suggestion, send us an e-mail: help@w3schools.com · HTML Tutorial CSS Tutorial JavaScript Tutorial How To Tutorial SQL Tutorial Python Tutorial W3.CSS Tutorial Bootstrap Tutorial PHP Tutorial Java Tutorial C++ Tutorial jQuery Tutorial
🌐
GeeksforGeeks
geeksforgeeks.org › html › how-to-check-for-errors-in-html
How to check for errors in HTML ? - GeeksforGeeks
October 31, 2021 - Javascript · React · A to Z Guide ... forms before the browser displays it. In any code, 2 types of errors are possible: Syntax error: Incorrect syntax leading to compile time error in other languages.HTML have no affect of ...
🌐
Testmuai
testmuai.com › testmu ai › blog › dealing with common javascript errors and effective handling | testmu ai
Dealing with Common JavaScript Errors and Effective Handling | TestMu AI (Formerly LambdaTest)
December 24, 2025 - To handle this issue, ensure that JavaScript code interacting with DOM elements executes after the DOM elements have been created. For instance, place your script tag at the end of the HTML body or use the DOMContentLoaded event to ensure the DOM is fully loaded before executing JavaScript:
🌐
Codecademy
codecademy.com › learn › javascript-errors-debugging › modules › errors-and-error-handling › cheatsheet
Learn JavaScript: Error Handling: Errors and Error Handling Cheatsheet | Codecademy
A JavaScript try…catch statement can anticipate and handle thrown errors (both built-in errors as well as those constructed with Error()) while allowing a program to continue running. Code that may throw an error(s) when executed is written within the try block, and actions for handling these errors are written within the catch block.