Clean HTML and Javascript

When a site is being developed, it’s easy for the source code to become more complex and messy as the project moves along. However, it’s important to keep a site’s code clean and clear so that it’s easier to understand, especially if another developer may take over the project.

Clean code features less complexity and is easily understood by anyone on the development team. The code should follow a logical structure, with main site elements at the top and supplemental elements, like sidebars and footers, below. Code should also be easy to change since the site will likely go through multiple iterations. Some best practices for clean code include:

  • Use HTML and CSS validators
  • Use alt text for <img> tags
  • Give classes meaningful, easily understood names
  • Avoid using unnecessary wrappers
  • Indent code to show parent/child relationships
  • Keep titles simple and clean with a clear hierarchy
  • Eliminate unnecessary divs

There are also online tools available to help beautify your code, such as Prettier and ESLint, which focuses on Javascript.

Share: