Why You Should Comment Your Code

Taking a look at any type of code can be a bit terrifying for beginners, but if there are comments in the code it makes it a little easier. Comments can help point out which section is which and what is what. Using comments throughout your code is not only helpful to others who are looking at it, but it can also be helpful to you. If you have hundreds of lines of code and are trying to go back through it all to make a correction or change, it is much easier to find that certain section if you have placed comments throughout.  There are many other reasons why comments can be helpful besides keeping track of where sections are. Comments can also be used to keep track of information, such as the author, date the code was created, and the date it was last updated. This is all information that you want in the document, but don’t want to display on the webpage. Another way that comments can be helpful is if you are trying to see how a webpage would look without a certain section. For doing this you could simply just add the comment codes around the section that you want to take out and if you decide later to keep the section, then you just have to erase the comment codes instead of having to retype the whole section of code. WordPress.org explains really well how to add comments into your code for these different reasons and shows you exactly how to type them out. I will point out the two that I use most, but WordPress also shows you how to do  comments with PHP.

Comments in HTML look like this:

<!– Comment Here –>

Comments in CSS look like this:

/* Comment Here */


“Commenting Code,” WordPress, http://codex.wordpress.org/Commenting_CodeCode


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s