Comments: HTML, Javascript, CSS and PHP

Table of Contents

Creating HTML comments to issue or document codes

Comments are used so that a particular line of code or block of lines is ignored. The purpose of using comment may be simply to document the code or skip certain line for error debugging effect.

The use of comments can be done in HTML, Javascript, CSS, PHP, ASP, ASP.NET and other languages.

HTML comments

HTML comment can be used in two ways: comment a single line or a block of lines, see below the two examples in an HTML document.

<html xmlns = ” https://www.w3.org/1999/xhtml “>

<head>

    <title> HTML comments </ title>

</ head>

<body>

    <! – This is a comment of a single line ->

    <h1> page title </ h1>

    <! – Start of blog to comment

    <ul>

        <li> This is a comment </ li>

        . <li> block </ li>

        <li> Right? </ li>

    </ ul>

    end of blog comment ->

</ body>

</ html>

Javascript and PHP comments

Javascript and PHP also allow the use of comments and just like HTML, it can be from a single line or in Blocks.

Comments for a single line will be started by // (two slashes), already block comments will start with / * (slash and asterisk) and end with * / (asterisk and slash).

See the example below:

// This is a one line comment

/ * This is a block comment

ie

in several lines * /

CSS Comments

CSS allows the use of comments only in blocks, using the same characters as Javascript and PHP.

Example:

/ * This is a block comment in CSS

ie

in multiple lines * /

ASP and ASP.NET Comments

ASP and ASP.NET also allows the use of comments, in these cases the character used to make single-line comments is *** (single quotation marks).

* In the case of ASP.NET simple quotes are used if the language chosen is VB.NET

As explained at the beginning of the post, comments can be used to document the beginning of the code with author information, document creation date, and purpose. I believe this option should be most appreciated by older programmers who have this inheritance from other programming languages.

A good practice for using HTML comments is to comment the text within <SCRIPT> and <STYLE> to prevent older browsers that do not support scripting or styles from displaying plain text.

Fully Managed WordPress Hosting

Nestify’s AWS powered dedicated CPU servers keep your sites fast, secure, and always up to date.

Want faster WordPress?

WordPress Speed Optimization

Try our AWS powered WordPress hosting for free and see the difference for yourself.

No Credit Card Required.

Whitelabel Web Hosting Portal Demo

Launching WordPress on AWS takes just one minute with Nestify.

Launching WooCommerce on AWS takes just one minute with Nestify.