简体   繁体   中英

CSS Best Practice - Color Palette

I'm new to web development and I've been working with stylesheets as needed. My question is, for one website, we have a specific set of colors to use for consistency. I don't know the hex values well enough to see them and know off hand it's red (or a flavor of it), green, blue, etc.

Would it make sense to have a comment at the top that is a "color reference" for the given site?

Example:

/*
 [Site Name] Color Standards
 Red:   Specific #hexvalue for shade of red being used.
 White: #FFF or #FFFFFF
 Black: #000 or #000000
 Yellow: Specific #hexvalue for shade of yellow being used.
 and so on...
*/

I have not seen that in any of stylesheet examples around the web or anywhere else. As one who does not work with stylesheets on an "as needed" basis, I think this would be a good standard. (I will certainly use it going forward.) I would understand why someone who works with them constantly would find this useless and would not do it.

Edit: In response to comments: I (poorly) chose to have black and white in there as part of the example, but what I was getting at is why isn't done as a standard. The design document may not always be available (but I agree that it should). I wrote this after I started doing web development (which is new to me) and I just thought that something like this would make sense so that anyone could come into the stylesheet know what colors to use to keep the colors on the site consistent. If something like this were done, there would be no need to rely on an additonal resource: the original designer (who might have moved on), design document (which may or may not be available), or anybody else in the office/on the team.

我认为这是一个好主意,并且很少见,你应该看一看。

There's no standard for this or yes and no answer, so if you find it helps to keep hex references at the top of your style sheet in a comment, go for it. You're not going to get punished for it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM