HTML, CSS, PHP, Javascript and Jquery Code Commenting

This post explains how to code comment with HTML, CSS, PHP, Javascript and Jquery Code.

In this article we’ll explore the use of code comments within the most common coding languages used within WordPress. Code commenting is the simple process of adding comments to give additional information that goes with the code but isn’t run or executed as code.

HTML:

In HTML code comments are opened with <!– and closed with –>

For example:

<!– This is a code comment above a HTML text block –>

<p> Lorem Ipsum Dolor Sit Amet </p>

This style of code comment can cover one or multiple lines.

PHP:

In PHP code comments can cover one or multiple lines but the way that they’re identified is different.

A one line comment uses // and a multiple line comment uses /* to open the comment and */ to close the comment.

For example:

//This is a one line code comment in PHP

/*
This is a code comment
It is on multiple lines
*/

CSS:

CSS code comments are very similar to PHP code comments but they just use /* as an opening tag and */ as a closing tag, there isn’t a one line code comment format.

For example:

/* This is a CSS code comment */

H1 {

Font-size: 24px;

}

Javascript:

Javascript is very similar to PHP; it uses the same structure for multiple or one line of code comments.

For example:

// This is one line of code comments

/*
This is multiple lines of code comments
Explaining exactly what the code does

*/ 

Jquery:

Jquery is exactly the same as Javascript and PHP using one line comments and multiple line comments in the same format.

For Example:

//This is one line of code comments

/* This is multiple lines of code comments
Explaining exactly what the code does
*/

Check out our article on adding CSS to WordPress to get started with some code commenting on your website!

So overall most of the major coding languages used within the WordPress interface are very similar to one another when it comes to code commenting. We’d appreciate a share or any comments if you found this useful, thanks!

Tech Typed
Tech Typed
Articles: 186

Leave a Reply

Your email address will not be published. Required fields are marked *