Thursday, 14 May 2020

Comments in HTML, CSS, C, C++, JAVA, JSP

Comments in HTML, CSS, C, C++, JAVA


In this we see comments in C,  C++,  java , HTML, CSS.

CSS Comments:

The CSS Comments are generally used to describe the code, and it may help when you mant to edit the source code later on.

The CSS Comments are ignored by browsers.

A CSS (cascading style sheet ) comment starts with /* (slash asterisk) and ends with */ (asterisk slash).

example1:

 /* This is a single-line comment in css  setting the color to white and background-color to black */
h1 {
  color: white;
  background-color:black;
}

example2

h1 {
  color: red;  /* Setting the text color to red */
  background-color:green; /* Setting the text background-color to green */
}

we can have multi-line comments in css i.e; we can specify multiple lines of comments. If comments are very long we go for multi-line comments

example3

/* This is
a multi-line
comment in css
here we are setting the color to white and background-color to orange .

*/

h1 {
  color: white;
  background-color:orange;
}


A sample program on comments

<!DOCTYPE html>
<html>
<head>
<style>
/* This is a single-line comment */
h1 {
  color: white;
  background-color:black;
}
h2 {
  color: red;  /* Setting the text color to red */
  background-color:green; /* Set text background-color to green */
}

/* This is
a multi-line
comment
here we are setting the color to white and background-color to orange .

*/

h3 {
  color: white;
  background-color:orange;
}

</style>
</head>
<body>

<h1>Hello World!</h1>
<h2>This paragraph is styled with CSS.</h2>
<h3> comments are not shown in the output.</h3>

</body>
</html>



HTML Comments:

In HTML comments will not be displayed in the browser ie; whatever we write will nor be displayed in browser. These comments will be there in html file describing the html content.

syntax.

   
<!-- specify your comments here -->




Comments in C language :


The  comments are used to  explain or describe what we are going to code or describe in the source code of the program.
In c programming language there are two types of comments :
    a) single line comment
        a single line comment will prefixed with //
    b) multi-line comments
        A multi-line comment that starts with a /*  (slash asterisk)  and finishes with an */  (asterisk slash)
we can place these comments anywhere in your code.
we can have any number of comments in a single program.

// A sample C program on comment
// Single Line comment
#include <stdio.h>
void  main()
{
 
    // This is a single line comment
    printf("Hello");
   
}







Comments in c++:

Like how we are having comments in c language similarlly we are having comments in c++ programming also.
In C++ also we have  single-line and multi-line comments. whatever character we write in between them  will be ignored by compiler.
single line comment.
     // This is  single line comment in c++ program .


multi-line comment.

/* C++ multi-line comments .
   we can have multiple lines of text as comment describing the code.
*/

A sample program on comment in c++

#include <iostream>

void  main() {
  cout << "Hello welcome to comments in c++ !"; // This is a comment
 
}

#include <iostream>

void  main() {
    /*This is a multi line comment in c++ .
       we are display hello.       
    */

  cout << "Hello welcome to comments in c++ !"; // This is a comment.
 
}


Comments in java:

Like how we are having comments in programming languages like c, c++ similarlly we are having comments in programming language like java.
In java  we have  two types of comments they are as folows
    1) single-line and
    2) multi-line comments.
whether single-line or multi-line whatever character we write in between  them will be ignored by the compiler.
single line comment.
     // This is a single line comment in java .


multi-line comment.
/* java multi-line comments .
   we can have multiple lines of text as comment
   providing some description of  the code in our program.
*/

Example program on single line comment.
class classone
{
    public static void main(String args[])
    { 
         // Single line comment in java.
            // Displaying hello on screen
         System.out.println("hello"); 
    }
}


Example program on multi line comment.
class CassTwo
{
    public static void main(String args[])
    { 
      int a=10,b=20,c;
         /* multi line comment in java.
            adding two number and
            displaying the sum .
            */
            c=a+b;
         System.out.println ("sum = "+ c); 
    }
}



Comments in JSP:

JSP stands for java server pages. It is used for developing dynamic web based applications.
In jsp we specify comments as below

<%-- This is a we specify comment in JSP  --%>

No comments:

Post a Comment