473,659 Members | 3,162 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

colour palettes and CSS

Hello,

I am new to CSS and come from an embedded/electronics background. Could some help with a question on
colours and palettes using named colours rather than hex values (ie color: #aabbcc). Could not find
a solution either in my CSS book or scouring the web.

As far as I can tell colours are set using pre-determined named colours (red, blue etc) or hex
colour values (eg color: #aabbcc). These can be applied to html selectors, classes and so on in a
style sheet. However, there are many selectors and may be many classes, IDs. My current knowledge is
that I have to set the colour for each selector individually using hex values (if I do not want the
preset colours). There may be many places where a single colour is used and hence to change that
colour requires manually spotting them in the CSS file by there hex values and appropriately
changing them. This is likely to be an error prone process. Too easy to miss an instance of a colour.

My embedded background leads me to want to write:
/* create a custom palette */
#define MAINTEXT #aabbcc
#define MAINBGND #100808

/* specify colours using my custom palette names */
body { color: MAINTEXT; background-color: MAINBGND; }

Thereafter I only need to change the palette definitions and everything referring to those colours
will follow the change. Also, meaningful names seems a little easier on the mind.

Can such a 'custom' palette be defined and used in CSS?

Any help on this greatly appreciated,
Regards
John Pote
Jul 2 '06 #1
2 1772
Els
John Pote wrote:
Hello,

I am new to CSS and come from an embedded/electronics background. Could some help with a question on
colours and palettes using named colours rather than hex values (ie color: #aabbcc). Could not find
a solution either in my CSS book or scouring the web.

As far as I can tell colours are set using pre-determined named colours (red, blue etc) or hex
colour values (eg color: #aabbcc). These can be applied to html selectors, classes and so on in a
style sheet. However, there are many selectors and may be many classes, IDs. My current knowledge is
that I have to set the colour for each selector individually using hex values (if I do not want the
preset colours). There may be many places where a single colour is used and hence to change that
colour requires manually spotting them in the CSS file by there hex values and appropriately
changing them. This is likely to be an error prone process. Too easy to miss an instance of a colour.

My embedded background leads me to want to write:
/* create a custom palette */
#define MAINTEXT #aabbcc
#define MAINBGND #100808

/* specify colours using my custom palette names */
body { color: MAINTEXT; background-color: MAINBGND; }

Thereafter I only need to change the palette definitions and everything referring to those colours
will follow the change. Also, meaningful names seems a little easier on the mind.

Can such a 'custom' palette be defined and used in CSS?
Not exactly, but you can still make it a lot easier. Make a separate
colour stylesheet, and set comments to have meaningful text, and then
group the selectors:

/* MAINTEXT COLOURS */

body,
#content p,
td,
input{
color:#aabbcc;
background-color:#100808;
border-color:#aabbcc;
}

/* SIDEBAR AND FOOTER COLOURS */

div.class1 p,
div.class2 p,
div#footer p,
div#footer li{
color:#000011;
background-color:#FFFFEE;
border-color:#aabbcc;
}
--
Els http://locusmeus.com/
accessible web design: http://locusoptimus.com/

Now playing: Cinderella - Love's Got Me Doin' Time
Jul 2 '06 #2
John Pote <jo******@jptec hnical.co.ukwri tes:
As far as I can tell colours are set using pre-determined named
colours (red, blue etc) or hex colour values (eg color:
#aabbcc).
<http://www.w3.org/TR/REC-CSS2/syndata.html#va lue-def-color>
My current knowledge is that I have to set the colour
for each selector individually using hex values (if I do not want the
preset colours).
You can group selectors as you like.

<http://www.w3.org/TR/REC-CSS2/selector.html#g rouping>
My embedded background leads me to want to write:
/* create a custom palette */
#define MAINTEXT #aabbcc
#define MAINBGND #100808

/* specify colours using my custom palette names */
body { color: MAINTEXT; background-color: MAINBGND; }
There's nothing like that in CSS, but nothing stops you from using a
(preferably local) preprocessor to mangle your CSS files.
--
||| hexadecimal EBB
o-o decimal 3771
--oOo--( )--oOo-- octal 7273
205 goodbye binary 111010111011
Jul 3 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
5230
by: Louise | last post by:
Hi I have written an HTML pages which does not have any colour specifying tags as far I know. When I view this in an Microsoft internet explorer browser it appears with a white background and black text but when I change Windows start menu->settings->control panel ->display -> appearance and change scheme to 'High Contrast Black' the background in the browser changes to black and the text to white. I understand that the windows scheme...
1
1755
by: Wayne | last post by:
I'm interested to know if I am the only person in the world who hates the default Windows XP colour scheme ie. Blue. Whoever was in charge of this in the Windows design team must have been either colour blind or mad! If they wanted to choose a more imposing colour, red is about the only one left! Lets face it, the average Windows user leaves their colour scheme at the default, which means that all my sized Access forms not only have...
2
1798
by: Carl Gilbert | last post by:
Hi I am looking to edit an icon at runtime on menu items such as change fill colour. I wish to replicate the features found in most applications where by the coloured bar on a colour picker icon changes colour to the last selected colour. Therefore the user can easily tell which colour will be apllied when
11
8063
by: Tim Marshall | last post by:
I use Terry Kreft's & Stephen Lebans colour dialog procedures for users to pick colours for various control properties in certain apps. Is there a way to take the colour code that is displayed in a backcolor/forecolor/etc property and calculate the "reverse colour"? In other words, If a user picks 255 (red) for a control backcolor, I'd like to be able to calculate the opposite or negative of that colour and assign the control's...
10
3481
by: Pulzar | last post by:
Hi there, I want to show a simple image on a web page, and allow the viewer to select and change one of the colours used in the image, and immediately preview the result. I'd like to keep the image processing away from the server to make the colour selection/preview process quicker, and I also don't want to pre-generate all possible images as there are too many colours that can be selected. Does JS (or any JS libraries) provide image...
20
3158
by: Chor Lit | last post by:
Hi, I asked Bjarne Stroustrup about the idea of adding colour standard for C++, and he said that it is very difficult for compiler vendors to change their IDE. But do you think it is possible ? Note that the proposed colour standard is not just merely to ease the eye only as what presently is in C++ compilers, but to aid in syntax disambiguation and other advantages. Here are a few advantages that I can think of:
0
1589
by: Badino | last post by:
Hi, Can someone tell me what to put in this code so that if a user selects 0 (Black) then make the font white (0) as my default colour is black on my Excel spreadsheet. Private Type CHOOSECOLOUR lStructSize As Long hwndOwner As Long Hinstance As Long rgbResult As Long lpCustColors As String
4
3716
by: Johny | last post by:
I use PIL to write some text to a picture.The text must be seen wery clearly. I write the text to different pictures but to the same position. As pictures maybe different, colour, in the position where I write the text, is also different. Is there a way how to set the font colour so that it will be seen very clearly in the picture? For example, if the picture is bright ( for example yellow), the font colour should be dark( e.g. black)...
6
2705
Robbie
by: Robbie | last post by:
Hi. I've made 2 functions which play around with colours. They convert a 'colour number' (I don't know what the proper name for it is, so I call it this - the Long given back by RGB(), object.BackColor, etc, which represents a value of red, green and blue) into another 'colour number' but this is a greyscale version of it. There are 2 functions - the first one 'decodes' the 'colour number' into the separate R G and B values. The second one...
0
8851
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8748
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8531
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8628
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7359
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6181
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5650
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
2
1978
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1739
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.