Monday, October 4, 2010

Flagging Rules in Css

Basic comments are of great benefit when scrolling through a style sheet, but there is a quicker
way to track down a rule—vital with large style sheets. Douglas Bowman (www.stopdesign.com)
introduced the idea of flags, where a character not typically found in style sheets is used at the
beginning of a comment to aid retrieval in conjunction with your text editor’s Find tool. It
should also be noted at this point that some CSS-specific software such as TopStyle and CSSEdit
have selector searches built into their feature sets.
Doug suggests adding an equals sign at the beginning of the comment, immediately
followed by the selector to act as a flag. Doing a search in the style sheet for p would typically
find all instances of p, either alone or within other words, and would be pretty useless. However,
searching for =p would bring the rule into focus immediately, as that character combination is
unlikely to appear anywhere else


. /* =p Default styling for paragraphs
-------------------------------------------------------- */
p {
color: #F00;
font-size: 12px;
}
This technique requires discipline, and is something to either adopt completely or leave
well alone. You could end up searching for something you think you’ve flagged, but haven’t.
Therefore I recommend that you flag all rules in this way if you intend to make use of this method.

No comments:

Post a Comment