Web Development

CSS – Comment and Example

css comment and example

CSS Comments

Comments are a useful source to define our code or to make a coder understand the code applied.

This may help us edit our code in the future. Comments are not displayed by browsers.

CSS comments start with /* and end with */

Why Are Comments Required?

Comments are required to make code understandable; we don’t have to think we are not only the coder, or programmer.

If another engineer or developer checks any part of the code, then S/He should know what is that code and why that code exists. So it’s better to put comments in while doing the coding.

CSS Example

The declaration part must end with a semicolon and curly braces after each declaration.

h1{
background-color: 0f0;

/* header level one background color is green – 0f0 – for Single Line Comment */ text-align: left; /* text align is always left for all header level one -for Multi Line Comment */ }

Comments are always ignored by the browser; the browser won’t display the comments. It is only used to make code readable.

Unfortunately, CSS doesn’t have any easy way to add single-line comments. Like in JavaScript, you can do this.

JavaScript Example
//This is the single-line comment in JavaScript

Here you are using two backslashes for commenting on the line in JavaScript

Tuts

About Author

Tutsmaster.org provides tutorials related to tech and programmings. We are also setting up a community for the users and students.

You may also like

HTML introduction
Web Development

HTML – Introduction, History & Syntax

  • December 21, 2019
So, first of all, I would like to ask a question for the first time when you heard this term
html heading tag
Web Development

HTML – Heading Tag With Syntax

  • December 21, 2019
A heading tag is one of the most important tags we focus on in HTML or web development because, without