Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I want to use css, but am seduced by the FONT.

Status
Not open for further replies.

ghijkl

Programmer
Mar 23, 2003
17
AU
I am trying to display text from a database using css and HTML.
While i am satisfied with the layout and overall control given by css, i have great difficulty in doing the "simplest" things. I want to display text which changes color with no interruption to the layout of the line on which it appears - like the Delphi editor - highlighting certain types of text in different colors.
This can be achieved by embedding <FONT COLOR=???> within the text, and that works fine. But I want to broaden the functionality - i want to say <FONT CLASS=&quot;FONTCOLOR1&quot;>
But i cant get that to work - the class definitions seem ok - others work - but the color never changes.
I received advice on this forum - to use the SPAN tag, using the same class settings. This did not work either.
I would really like to take full advantage of CSS to reduce the repetition in HTML source. If anybody has a practical suggestion i would really appreciate to hear it.
 
try this

<div class=&quot;font1&quot;>blah blah blah</div><div class=&quot;font2&quot;>blah blah blah</div>.....and so on [Hammer]
Nike Failed Slogans -- &quot;Just Don't Do It!&quot;
 
Use this:

<style>
.first{
color:blue;
}
.second{
color:red;
}
</style>

normal text <span class=&quot;first&quot;>blue text</span> <span class=&quot;second&quot;>red text</span> normal text

Rick -----------------------------------------------------------
RISTMO Designs
Arab Church
 
Thankyou for your help - the problem has been fixed - i was using dots as delimiters in the class name - &quot;FONT.COLOR.1&quot; - changed to hyphens and ok now - &quot;FONT-COLOR-1&quot;
 
OK. Just an idea...It's good to use &quot;_&quot; instead of &quot;-&quot;, because other languages will have problems using &quot;-&quot;. If you get used to doing that now, that won't cause problems for you when you start learning new languages.

Rick -----------------------------------------------------------
RISTMO Designs
Arab Church
 
Whilst, like everyone, I don't always practice what I preach, I suggest you pick meaningful names for your classes. &quot;FONT_COLOR_1&quot; doesn't tell you anything, if you're looking at the HTML file you need to look at the CSS to see what it means, if you're looking at the CSS you'll have to look at the HTML to see where it's used.

It's tempting to name the class something like &quot;RED&quot;, but it's not a good idea. What if you decide to change the colour scheme of your site? You either have a class called RED that turns things, say, green, or you have to edit all your html to use a new class (in which case you might have well stuck with <font>).

Much better to name classes according to their usage. Call them things like &quot;highlight&quot;, &quot;menu_option&quot;, &quot;code&quot; or whatever - name them to show what they're FOR rather than what they DO. -- Chris Hunt
Extra Connections Ltd
 
Your advice should be in the standards. In this case, the names are generic. I have many textual objects that are generated into HTML. I am trying to come to a standard, and in this case I have decided that there should be a numbered list of 4 colors that will always display clearly, and that can be used to represent different contexts of data. 4 is the largest number of colors i have chosen to use within a (sub) document to achieve clarity.
I dont want to go browsing color charts more than once to find a set of text colors to use when I change the background color. And hopefully in the future I will not know the background color - it will be whatever the site uses as standard, so the site would have its own preferences of text color.
I would imagine that Essendon Football Club would use a black background, and have color.1 as red.


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top