Common Coding Mistakes - dummies

Common Coding Mistakes

By Nikhil Abraham

Part of Coding For Dummies Cheat Sheet

Code not working? Here are some common mistakes that can trip up even the most experienced coder. If your code won’t run, try running down this checklist to see if you have any of these errors:

  • Not having a closing HTML tag </element> after every opening HTML tag <element>.

  • Missing brackets < or > in HTML.

  • Missing curly braces, colons, or semicolons in CSS, as in the following:

    h1 {
      color: blue;
    }
  • Missing curly braces in JavaScript, especially for if statements.

  • Forgetting to have a pair of closing pair of quotes for every opening pair of quotes.

  • Having more than one opening and closing <html> tag, <head> tag, or <body> tag.

  • Putting HTML code in the CSS file or section, and putting CSS code in the HTML section. If the code deals with style and appearance, it’s likely CSS.

  • Not linking to your CSS file using the <script> tag, and so your CSS effects don’t render in the browser.

  • Misspelling a part of a command, as in <img scr=”logo.jpg”>, which is incorrect because the attribute is spelled src not scr.

  • Including attributes outside the opening HTML tag. For example, <img> src=”logo.jpg” is incorrect because the attribute is outside the opening image tag.