HTML and CSS Reference
In-Depth Information
Unfortunately, CSS doesn't have an easy way to present a valid, single-line comment that
uses just an opening comment character combo. For example, in JavaScript, you can com-
ment out a single line of code like this:
// This is a JavaScript comment
This is helpful in JavaScript because it makes it easy to nullify an entire line of code, or add a
helpful comment, with just two characters (the backslashes). But in CSS it's necessary to use
both the opening and closing characters to specify the boundaries of any comments.
For quick, temporary fixes, however, it's acceptable to create a sort of faux CSS comment by
applying the principle we discussed in the previous section on CSS errors. Let's say we have
the following CSS:
.center-global {
max-width: 1020px;
margin: 0 auto;
}
And let's say we want to temporarily remove the first line (the max-width declaration). We
could do this:
.center-global {
/* max-width: 1020px; */
margin: 0 auto;
}
This works fine, but a quicker way to achieve the same result is simply to put some random
characters at the beginning of the line, like so:
.center-global {
AAAAmax-width: 1020px;
margin: 0 auto;
}
It's quick and effective, but don't ever leave your CSS like this on a live website. It's not valid
CSS and should only be used in development for doing quick debugging.
Search WWH ::




Custom Search