• Home
  • PHP
  • MySQL
  • Demos
  • HTML
  • CSS
  • jQuery
  • Framework
  • Social
  • Request Tutorial
PHP Lift
  • Home
  • Demos
  • Advertisement
PHP Lift
  • Home
  • PHP
  • MySQL
  • Demos
  • HTML
  • CSS
  • jQuery
  • Framework
  • Social
  • Request Tutorial
  • Follow
    • Facebook
    • Twitter
    • Google+
    • Pinterest
    • Youtube
    • Instagram
    • RSS
Validation of HTML5 documents
Home
HTML 5

Validation of HTML5 documents

March 15th, 2017 Ivan Dimov HTML 5 0 comments

Facebook Twitter Google+ LinkedIn Pinterest

When creating pages, it is important for your website to be valid. That means there should be no errors in the HTML code of your webpages. This is not mandatory but it will provide a boost for your website; both in terms of consistency and search engine rankings.

  1. HTML5 documents start with the <!DOCTYPE html> declaration which is much shorter than previous versions such as XHTML and HTML 4.
  2. You don’t have to close void tags with a slash: you can just input <br> instead of <br /> if you desire
  3. Attributes need quotation signs only if there is a space in the attribute or other special characters such as an equals sign.
  4. Elements and attributes can be arbitrarily-cased (they could be in lowercase, uppercase or mixed case) and that would not be a problem.
  5. Some attributes and tags were deprecated in HTML5 so you should keep yourself from using them, such as the attributes target, scope, align, bgcolor, border, background, cellpadding, cellspacing and so on. You can get a full list of deprecated attributes and tags at: https://www.tutorialspoint.com/html5/html5_deprecated_tags.htm
  6. You should be okay if you put ampersands (&) as text on a page instead of writing them as an entity (&amp;)
  7. Void tags need not be closed; make sure you close all other tags that need a closing pair, like <p>…</p>
  8. In fact, you can add an arbitrarily named tag or attribute in HTML5 and the browser will render the page but the tags/attributes may not constitute a valid HTML5 document. A custom HTML5 element must have a dash in its name and you should be using the data attribute for arbitrary attributes instead of just inserting arbitrary attributes.
  9. The alt attribute for images (<img>) is still required
  10. Do not place block-level elements such as <p> inside inline-level elements such as <button>
  11. Identifiers (id attributes) and class names should not contain a whitespace inside their name.
  12. Avoid duplicate declaration of attributes on the same element
  13. You should close all non-void tags, closing the container tag without closing one of its children will still result in a validation error.

You can validate your pages one at a time at: https://validator.w3.org/. The validator will show the actual errors so that you can see what is wrong and resolve it. Therefore, it might be good to validate the documents regularly while your websites are in development. As usual, the errors are of the highest importance.

Share this:

  • Click to share on Twitter (Opens in new window)
  • Click to share on Facebook (Opens in new window)

Related

Facebook Twitter Google+ LinkedIn Pinterest
Next article Cool HTML5 features
Previous article JavaScript tips and tricks, Part 2

Ivan Dimov

Ivan is a student of IT, a freelance web designer/developer and a tech writer. He deals with both front-end and back-end stuff. Whenever he is not in front of an Internet-enabled device he is probably reading a book or traveling. You can find more about him at: http://www.dimoff.biz. facebook, twitter

Related Posts

7 HTML attributes that you must learn today! HTML 5
February 3rd, 2022

7 HTML attributes that you must learn today!

How to show Image before upload JavaScript & HTML5 FileReader() API
November 2nd, 2020

How to show Image before upload JavaScript & HTML5 FileReader()

Javascript Image Compress using HTML5 Canvas & File API before Upload HTML 5
October 14th, 2019

Javascript Image Compress using HTML5 Canvas & File API before Upload

Leave a Reply Cancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

    Advertisement
    Like us
    Recent Posts
    • How to Extract Text from PDF using PHP
    • 3 reasons why you SHOULD write tests
    • How to create a screen recorder in JavaScript
    • Best 10 Programming Languages that will rule in 2022
    • Top 7 Websites To Get Your First Paid Internship
    Categories
    • API
    • Bootstrap
    • Bot
    • CSS
    • CSS 3
    • Database
    • Designing
    • Framework
    • Guide
    • HTML
    • HTML 5
    • JavaScript
    • jQuery
    • MySQL
    • Node.js
    • oAuth
    • Payment
    • PHP
    • Python
    • Social
    • Tips
    • WordPress
    Weekly Tags
    • PHP
    • How to
    • javascript
    • api
    • MYSQL
    • jQuery
    • PHP Basics
    • Programming Habits
    • HTML5
    • PHP framework
    • About
    • Privacy Policy
    • Back to top
    © PHPLift 2021. All rights reserved.