Log in

View Full Version : "Correct" Way to Add Custom CSS?


Amaury
08-15-2013, 07:41 PM
Not so much "correct," which is why it's in quotation marks, but what the majority of people do.

For example, the Folder Picker text on the private.php page isn't controlled by blockhead_color by default; it's controlled by something else that I don't remember now.

To make it be controlled by blockhead_color, I would do this:
.popupgroup .popupmenu a.popupctrl {
color: {vb:stylevar blockhead_color};
}However, I've seen some people that do things like this:

.popupgroup .popupmenu a.popupctrl { color: {vb:stylevar blockhead_color}; }.popupgroup .popupmenu a.popupctrl {
color: {vb:stylevar blockhead_color};
}I always do it the first way I listed here.

tbworld
08-15-2013, 08:26 PM
What your talking about is "conventions" in CSS coding. Syntactically they are all correct to the parser. When starting off with CSS use your first method, the method you are using. After writing allot of CSS you find reasons to use the "long" method (method2) in some applications. It all depends on readability.

Seems like your on the right track :)

On a large project, good CSS planning is an art.

John Lester
08-16-2013, 05:29 PM
I find the "short" way (first example) much easier to read and follow when looking at hundreds of lines of CSS. Of course the only difference is readability and page size.