coding standards. As you learn to write WordPress code you might come across the concept of coding
standards. In this lesson you'll learn what coding standards are and why they're important
where to find information on each coding standard and learn about some useful coding standard
tools. What are coding standards? Coding standards also known as coding conventions are a set of
guidelines for a programming language. These standards recommend a programming style, practices
and methods for each aspect of the code. Having coding standards creates a baseline for
collaboration and review within a project or a community. Coding standards help avoid common
coding errors, improve the readability of code and simplify modification. Following the
standard means that anyone will be able to understand your code and modify it, if needed,
without regard for when it was written or by whom. Coding standards for WordPress. While
there are many coding standards available for writing code in PHP, JavaScript, CSS or HTML,
WordPress has its own set of standards that it uses for its core code and recommends for plugins
and themes. If you plan to write WordPress code it's a good idea to familiarize yourself with
these standards. Although it's not required that your code adheres to these standards, adopting
them will make your WordPress code easier for other developers to read and understand, enhancing
collaboration. The WordPress project maintains a handbook with all the information you need to understand
these standards. This handbook includes sections for four different languages that WordPress uses,
as well as a section on accessibility standards. For this lesson we'll focus on the language-specific
standards for HTML, CSS, JavaScript and PHP. HTML coding standards. The HTML coding standards
follow the worldwide web consortium standards for HTML and CSS, also known as the W3C standards
for HTML and CSS. The HTML standards page in the WordPress handbook is concise, mostly
deferring to the W3C standards, with specific notes on self-closing elements, attributes and
tags, quotes and indentation. CSS coding standards. Like the HTML standards, the CSS coding standards
also follow the worldwide web consortium standards for HTML and CSS. The WordPress CSS standards
page, however, provides more detailed information on topics like CSS structure, selectors, properties
and more. JavaScript coding standards. Unlike the HTML and CSS standards, the page on WordPress
JavaScript coding standards is more detailed. The JavaScript coding standards were originally adopted
from the jQuery JavaScript style guide, and have evolved over time as WordPress's expanded
its use of JavaScript. PHP coding standards. Of all the coding standards, the PHP coding standards
are the most detailed among the WordPress language-specific standards. This is because approximately
80% of WordPress core is written in PHP. The WordPress PHP coding standards were originally
adapted from the pair coding standards, but have since evolved into a specific set of standards
tailored for writing PHP code within the WordPress context. Tools for checking coding standards.
For HTML and CSS, you can use the W3C HTML validator and the W3C CSS validator to check your code for
errors. Additionally, for CSS, JavaScript and PHP, there are several linters available. A linter
is a tool that automatically checks your code against the specific coding standard. For JavaScript
and CSS, you can install and configure the WordPress script package, which includes linters for both
CSS and JavaScript. Finally, for PHP, you can use the PHP code snippet tool with the WordPress
coding standards Sniffs. Each of these linting tools requires some setup, but once installed,
you can run them on your code base to check for errors and style issues. You'll learn how to
install and use these tools in a future lesson.