Valid HTML

  • HTML is a specific list of tags that you are allowed to use.
  • Tags have specific attributes that they are allowed to include.
  • Some tags are only allowed to have certain tags as children and other tags are only allowed to be inside specific ones.

A common example is with list elements. Inside a <ol> or a <ul> the first child element MUST be an <li> tag. Nothing else is allowed here.

Validation Tools

Many IDEs like VSCode have some validation built-in. They will correct some mistakes that you make. However, not all the validation issues can or will be corrected instantly.

To test your HTML files, try using this tool:

W3C Validator

You can copy and paste your HTML into the validator, or upload your file, or provide a URL to the validator. The URL must be an externally visible one. A link that starts with http://localhost/ which points to a location on your own computer will NOT work.

Basic HTML Rules

  1. All tags need to have a matching closing tag or be self-closing.
  2. Tags should be written in lower-case
  3. Tag names never start with a number.
  4. All attribute values should have double-quotes around their value.
  5. Ampersands and double quotes should be written as character entities &amp;
  6. Comments should be wrapped in <!-- this is a comment -->
  7. Self-closing tags can be written with an opening and a closing tag. Eg: <img></img>
  8. The first line of every HTML file should be the Doctype declaration.
  9. The root element of every HTML file is the <html></html> element.
  10. All id attribute values need to be unique within each page.

More about quotation marks in webpages:

Last Updated: : 8/24/2019, 2:32:09 PM