Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialrajbee
6,657 Pointshex vs decimal for color codes and custom color names ?
Why is hex preferred over decimal to generate color codes ? Humans are more familiar with decimal. If you can use plain, self describing english like code in css, then why not use decimal ?
Can we create a name or alias for a particular hex color ? eg #676767 = @@supercool
2 Answers
Wesley Wright
26,793 PointsFor that, you are going to need a CSS preprocessor like Sass or Less. Both Sass and Less will allow you to do that, and they are both really powerful. Treehouse has Sass lessons.
Perhaps eventually, CSS will allow variables, but for now we are stuck using preprocessors to mimick that functionality.
This should get you started: http://teamtreehouse.com/library/sass-basics
Gunhoo Yoon
5,027 PointsAs far as I know, with plain html and css you are tied to whatever pre-defined values they give you. Maybe there is a way to work with DOM so you can create custom alias but I don't think that's really worth it.
But there is a way if you decide to use CSS pre-processor called SASS or LESS. With that you can assign variables and use them throughout your style sheet like $supercool = #676767.
I assume hex color is preferred because it's really straightforward once you get familiar and less typing :). Try this link http://www.color-hex.com/ pretty helpful if you are struggling with using hex color.