Best practices
Best practices is a relative term for obvious reasons. What is considered best is rather dependent on the team in which you work and what version of JavaScript you work with. In this section, we will try to cast a wide net over some of these best practices, and get an understanding of what some of the practices look like so that we can adapt and use them as well.
Best practices for HTML
Let's approach this section top-down and address the best practices for each of the sections within an HTML file.
Declaring the correct DOCTYPE
Have you ever wondered why we have <!DOCTYPE html>
at the top of our page? We can clearly leave it out, and still the page seems to work. Then, why exactly do we need this? The answer is avoiding backward compatibility—if we do not specify the DOCTYPE, the browser that is interpreting and rendering our HTML goes into quirks mode, which is a technique to support really old websites that were built with outdated versions and markups of HTML, CSS, and...