Comments in Code
July 23, 2021 • CSS, HTML, Javascript, PHP, SQL • Published By Josh • 2 minute read
Comments in code can be used to better explain what is going on and make it more readable. They can also be used to prevent code execution. Let’s take a look at how to comment code in a variety of languages!
Table of Contents
C/C++
// This is a single line comment in C/C++.
/*
This is a
multi-line comment
in C/C++.
*/
CSS
/* This is a single line comment in CSS. */
/* This is a
multi-line comment
in CSS. /*
HTML
<!-- This is a single line comment in HTML. -->
<!-- This is a
multi-line comment
in HTML. -->
Java
// This is a single line comment in Java.
/*
This is a
multi-line comment
in Java.
*/
Javascript
// This is a single line comment in Javascript.
/*
This is a
multi-line comment
in Javascript.
*/
PHP
// This is a single line comment in PHP.
# This is a single line comment in PHP.
/*
This is a
multi-line comment
in PHP.
*/
Python
# This is a single line comment in Python.
# This is a
# multi-line comment
# in Python.
SQL
-- This is a single line comment in SQL.
-- This is a
-- multi-line comment
-- in SQL.
YAML
# This is a single line comment in YAML.
# This is a
# multi-line comment
# in YAML.