473,748 Members | 4,065 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How is multi-color text/font done in CSS?

I'm a newbie to CSS, so be kind. :-)

I have looked at examples of CSS and have not seen this yet. How can
you change the colors of the text in the same word in CSS? For example,
when how can you take the word "infosystem s" and make the "info" part
red, and the "systems" part blue? I don't want to have to hard-code
this in HTML which is why I'm looking to CSS to do this. Thanks!

Jan 18 '07 #1
28 40636
eastcoastguyz wrote on 18 jan 2007 in
comp.infosystem s.www.authoring.stylesheets:
I'm a newbie to CSS, so be kind. :-)

I have looked at examples of CSS and have not seen this yet. How can
you change the colors of the text in the same word in CSS? For example,
when how can you take the word "infosystem s" and make the "info" part
red, and the "systems" part blue?
<span style='color:re d;'>
info</span><span style='color:bl ue;'>systems</span>

I don't want to have to hard-code
this in HTML which is why I'm looking to CSS to do this. Thanks!
"hard-code" ?
CSS is no softy!

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jan 18 '07 #2
On Thu, 18 Jan 2007, eastcoastguyz wrote:
How can
you change the colors of the text in the same word in CSS? For example,
when how can you take the word "infosystem s" and make the "info" part
red, and the "systems" part blue?
Example:
http://www.unics.uni-hannover.de/nht.../rainbow.html6
Jan 18 '07 #3

eastcoastguyz wrote:
For example,
when how can you take the word "infosystem s" and make the "info" part
red, and the "systems" part blue?

<style type="text/css" >
..highlight { color: red; }
..lowlight { color: blue; }
</style>

<p>
<span class="highligh t" >info</span><span class="lowlight "
>systems</span>
</p>

I don't want to have to hard-code
this in HTML which is why I'm looking to CSS to do this.
Hard-code suitably abstract class or id values into the HTML, then
attach the specific styles through CSS.
If your classes are appropriate, it's not aproblem to have hard-coded
them

Jan 18 '07 #4

Andy Dingley wrote:
eastcoastguyz wrote:
For example,
when how can you take the word "infosystem s" and make the "info" part
red, and the "systems" part blue?


<style type="text/css" >
.highlight { color: red; }
.lowlight { color: blue; }
</style>

<p>
<span class="highligh t" >info</span><span class="lowlight "
systems</span>
</p>

I don't want to have to hard-code
this in HTML which is why I'm looking to CSS to do this.

Hard-code suitably abstract class or id values into the HTML, then
attach the specific styles through CSS.
If your classes are appropriate, it's not aproblem to have hard-coded
them
Thanks to all for replying.

What if you had the same word in this example, "infosystem s" and wanted
each letter to be a different color, would this require each letter be
addressed to a different span class? Thanks!

Jan 18 '07 #5
Scripsit eastcoastguyz:
What if you had the same word in this example, "infosystem s" and
wanted each letter to be a different color, would this require each
letter be addressed to a different span class? Thanks!
Yes, though in principle you could use some other tags than <span(but
<spanis safest since it means nothing and has no default styling in any
reasonable browser).

The very idea is so weird that it's perhaps just fine that it's cumbersome
to implement in CSS.

Note, by the way, that people who posted you some sample codes forgot to set
the background. You will now probably be inclined into making the same
common mistake. Doing _technically correctly_ the thing you want is actually
even more awkward than the simplistic examples suggest.

--
Jukka K. Korpela ("Yucca")
http://www.cs.tut.fi/~jkorpela/

Jan 18 '07 #6
In article
<11************ **********@51g2 000cwl.googlegr oups.com>,
"Andy Dingley" <di*****@codesm iths.comwrote:
eastcoastguyz wrote:
For example,
when how can you take the word "infosystem s" and make the "info" part
red, and the "systems" part blue?


<style type="text/css" >
.highlight { color: red; }
.lowlight { color: blue; }
</style>

<p>
<span class="highligh t" >info</span><span class="lowlight "
systems</span>
</p>
and put in a background colour too where while at it, eg.

..highlight { color: red; background: #fff;}

Since old K and I teamed up, he leaves me to mention the little
stuff, I am not to be trusted with anything bigger.

--
dorayme
Jan 19 '07 #7

Jukka K. Korpela wrote:
Note, by the way, that people who posted you some sample codes forgot to set
the background.
I didn't forget, I omitted it deliberately as being inappropriate.

There is no reason to set background colour in every CSS block. There's
no reason why every time colour is set, background colour needs to be
set too. The need is to ensure that unviewable combinations don't
arise. This can be achieved by crudely setting in pairs, or by by
carefully studying the overall stylesheet.

Usually it's a good idea to set both. Most uses of CSS blocks are
driven by applying the whole block to an element in a fairly simple
manner, with a "blanket" set of rules to apply. Setting only one
colour here would be likely to cause conflicts with inherited
backgrounds etc.

In this case though, the CSS is a little more obscure. We're applying a
simple "highlight" by actively controlling only one color. The other
color _should_ be left as inherited - we have no interest in changing
it. It's also a problem from maintenance reasons if we did set the pair
of colours. This breaches the good software principle of "Don't Repeat
Yourself" which is just as important as the CSS principle of "Don't set
only one colour next to an unknown inherited background".

It's necessary to know the scope in which this CSS rule is used. It's
necessary to know that the backgrounds possible in this scope can't
generate a conflict with the possible colours. If these conditions are
met by studying the page design, then there's no reason to duplicate a
hard-coded background setting into every block.

Of course this isn't perfect, in the case of some heavyweight user
stylesheet colour and background settings. But nor is the "set
everything twice" behaviour.

Jan 19 '07 #8
On Fri, 19 Jan 2007, Jukka K. Korpela wrote:
Yes, though in principle you could use some other tags than <span(but <span>
is safest since it means nothing and has no default styling in any reasonable
browser).
Even <spanmay break the joining of Arabic letters.
Note, by the way, that people who posted you some sample codes forgot to set
the background. You will now probably be inclined into making the same common
mistake.
Background for what? For span? Not even http://jigsaw.w3.org/css-validator/
with "Warnings: Normal report" reports this as warning, let alone as
"mistake" (= error).
Jan 19 '07 #9

Andreas Prilop wrote:
Even <spanmay break the joining of Arabic letters.
I'd suggest that the idea of alternately colouring arabic letters is so
aberrant that this simply isn't a problem. Even if it's an arabic
calligraphy instruction book and might _possibly_ want to apply some
sort of highlight. For a language like arabic that has stopped being
expressible as a character-based text problem and has become a
graphical issue.

Jan 19 '07 #10

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

Similar topics

0
3783
by: frankenberry | last post by:
I have multi-page tiff files. I need to extract individual frames from the multi-page tiffs and save them as single-page tiffs. 95% of the time I receive multi-page tiffs containing 1 or more black and white CCITT4 compressed files (frames) inside the tiff. Every now and then I receive a mixture of black and white CCITT4 and JPEG compressed files, and sometimes just multi-page tiffs with JPEG only. The code runs great when dealing with the...
6
4893
by: Joe | last post by:
I have 2 multi-list boxes, 1 displays course categories based on a table called CATEGORIES. This table has 2 fields CATEGORY_ID, CATEGORY_NAME The other multi-list box displays courses based on a table called COURSES. This table has 2 fields CATEGORY_ID, COURSE_NAME. The CATEGORY_ID is a FK in COURSES and a PK in CATEGORIES. I want to populate the course list box based on any category(s)
2
3038
by: google | last post by:
Hello everyone, I am having an issue using the "Multi Select" option in a list box in MS Access 2003. I am making a form that users can fill out to add an issue to the database. Each issue can be associated with multiple categories. I have an "Issue," "IssueCategory," and "Category" in the database (among other tables). The form has a subform in it which is tied to the "IssueCategory" table. The main form is tied to the "Issue"...
4
17873
by: mimmo | last post by:
Hi! I should convert the accented letters of a string in the correspondent letters not accented. But when I compile with -Wall it give me: warning: multi-character character constant Do the problem is the charset? How I can avoid this warning? But the worst thing isn't the warning, but that the program doesn't work! The program execute all other operations well, but it don't print the converted letters: for example, in the string...
1
1415
by: Bob Rock | last post by:
Hello, I was wondering when multi-file assemblies may be useful. With multi-file assemblies you may place inside the same assembly netmodules coded in different languages and as a consequence code from a module may obviously utilize private and internal classes defined in other module (maybe even coded in different languages). Apart this I personally see no other reasons to using multi-file assemblies.
17
10706
by: =?Utf-8?B?R2Vvcmdl?= | last post by:
Hello everyone, Wide character and multi-byte character are two popular encoding schemes on Windows. And wide character is using unicode encoding scheme. But each time I feel confused when talking with another team -- codepage -- at the same time. I am more confused when I saw sometimes we need codepage parameter for wide character conversion, and sometimes we do not need for conversion. Here are two examples,
0
2327
by: Sabri.Pllana | last post by:
We apologize if you receive multiple copies of this call for papers. *********************************************************************** 2008 International Workshop on Multi-Core Computing Systems (MuCoCoS'08) Barcelona, Spain, March 4 - 7, 2008; in conjunction with CISIS'08. <http://www.par.univie.ac.at/~pllana/mucocos08> *********************************************************************** Context
3
2092
by: Fred | last post by:
We all agree that multi-core is where the industry is headed. Can the .NET framework take advantage of multi-cores? are the programs written in .NET multi-threaded by default or is additional tweaking required? Will there be any new features in the new version of the .NET framework to extend multi-core capabilities? Fred
2
5552
by: Mirco Wahab | last post by:
After reading through some (open) Intel (CPU detection) C++ source (www.intel.com/cd/ids/developer/asmo-na/eng/276611.htm) I stumbled upon a sketchy use of multibyte characters - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 260: unsigned int VendorID = {0, 0, 0}; try // If CPUID instruction is supported {
14
3408
by: =?ISO-8859-1?Q?Tom=E1s_=D3_h=C9ilidhe?= | last post by:
As far as I know, the C Standard has no mention of multi-threaded programming; it has no mention of how to achieve multi-threaded programming, nor does it mention whether the language or its libraries are suitable for multi-threaded programming. For people who are fond of portable C programming, what's the best way to go about multi-threaded programming? I've been reading up on POSIX threads a little, they seem pretty ubiquitous....
0
9534
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
9366
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
9316
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
8239
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
6793
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
6073
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();...
0
4597
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3303
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2211
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.