Comments

Comments are necessary to make explanations as for the use of this or that CSS characteristic. It helps to remember the logic easily and the structure of the selectors and increases the  intelligibility of the code. It also increases the volume of the documents, and it influences the time of their downloading. That is why, the commentaries are usually applied in the finishing or educational purposes, but while outputting the site to the Internet they should be deleted.

In order to mark that the text is a comment, use the construction /* ... */ (example 8.1).

Example 8.1. Comments in CSS file.

1
2
3
4
5
6
7
8
9
10
/* 
  The style for the site htmlbook.ru
  Is made for introductory
*/
 
#toc { /* Block with the content */
  width: 200px; /* Width of the block */
  margin: 20px 0px 10px 0px; /* Fields around the element */
  float: left; /* Right floating */
}

As we see from the example comments can be added to any place of the document.
Example 8.2. Comments in HTML code.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
 <head>
  <meta http-equiv="Content-Type" content="text/html; charset=windows-1251">
  <title>Комментарии</title>
  <style type="text/css">
   P { 
    border: 5px double silver; /* Border parameters */
    padding: 5px; /* Fields around the text */
   }
  </style>
 </head>
 <body>
  <p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diem 
  nonummy nibh euismod tincidunt ut lacreet dolore magna aliguam erat volutpat.</p> 
 </body>
</html>

If it is necessary to disable some CSS property, you may determine additional symbol before the attribute, for example twiddle (~). In this case browser does not understand the parameter and skip it as unknown one.

Example 8.3. Comment on some CSS properties.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
 <head>
  <meta http-equiv="Content-Type" content="text/html; charset=windows-1251">
  <title>Comments</title>
  <style type="text/css">
   P { 
    border: 5px double silver; /* Border parameter */
    ~padding: 5px; /* Comment on this parameter */
   }
  </style>
 </head>
 <body>
  <p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diem 
  nonummy nibh euismod tincidunt ut lacreet dolore magna aliguam erat volutpat.</p> 
 </body>
</html>

Note
The given method of commenting the CSS characteristics is recommended to use only in the checkout purposes and should never be added into the final version of the site. This method comes into the conflict with CSS specification and leads to bugs during the code-checking on the point of validity.