As is the case with HTML, comment text can be added to style sheets as well. In a multipage template, this helps you remember which CSS rule applies to what or why it was added in the first place. CSS supports multiline comments that begin with a forward slash and an asterisk (/*) and terminate with an asterisk and a forward slash (*/). This is illustrated in Figure 2-7.
CSS comments provide a mechanism that allows you to insert notes about what the styles in the style sheet do and why they were added. The design of a website can get complicated, and often it’s helpful to make notes that help you remember why you added one thing or another. The following are some examples of what you can do with comments.
- Figure 2-8
- Comments can appear inside of a declaration, as demonstrated in Figure 2-9.Figure 2-9
- Comments can span multiple lines, as shown in Figure 2-10.Figure 2-10
- Comments can be used to disable portions of a style sheet, as shown in Figure 2-11.Figure 2-11
Disabling portions of a style sheet can be useful if you are trying to track down problematic styles, or if you are simply experimenting with different effects.