469,926 Members | 1,571 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,926 developers. It's quick & easy.

How to define an absolute overall text style class ?

I want to define a text style class which is active whenever I refer to it.
The following does not work

in CSS:
bluetext { COLOR: blue; FONT-SIZE:16px; }

in HTML:
.....
<TABLE><TR><TD>
<class=bluetext>this should appear in blue</class>
</TD>
<TDThis should appear in some other style</TD>
....

Even when I encapsulate it in a <Ptag it doesn't work

.....
<TABLE><TR><TD>
<P class=bluetext>this should appear in blue</P>
</TD>
<TDThis should appear in some other style</TD>
....

Why ?

Is there another wway ?

Keith
May 9 '07 #1
14 3095
On 2007-05-09, Keith Clark <k.*****@lucent.comwrote:
I want to define a text style class which is active whenever I refer to it.
The following does not work

in CSS:
bluetext { COLOR: blue; FONT-SIZE:16px; }
You need a . before bluetext. Currently that selects the bluetext
_element_ (which doesn't exist in HTML), not the bluetext class.
in HTML:
....
<TABLE><TR><TD>
<class=bluetext>this should appear in blue</class>
No there you're using a class element, which doesn't exist in HTML
either, and wouldn't match your selector either.
></TD>
<TDThis should appear in some other style</TD>
...

Even when I encapsulate it in a <Ptag it doesn't work

....
<TABLE><TR><TD>
<P class=bluetext>this should appear in blue</P>
That's more like it.
></TD>
<TDThis should appear in some other style</TD>
...

Why ?
You're just not getting the basic syntax right!
May 9 '07 #2
On 09 May 2007 08:59:29 GMT, k.*****@lucent.com (Keith Clark) wrote:
I want to define a text style class which is active whenever I refer to it.
The following does not work

in CSS:
bluetext { COLOR: blue; FONT-SIZE:16px; }
Perhaps
.bluetext { COLOR: blue; FONT-SIZE:16px; }
will work for you.

--
Steven
May 9 '07 #3
rf
"Keith Clark" <k.*****@lucent.comwrote in message
news:46**********************@newsspool2.arcor-online.net...
>I want to define a text style class which is active whenever I refer to it.
The following does not work

in CSS:
bluetext { COLOR: blue; FONT-SIZE:16px; }
..bluetext ...
<class=bluetext>this should appear in blue</class>
Bad idea however. What if you want to change the colour. Then you would
have:

..bluetext{color: red; ...

Better to call it .importantcell

--
Richard.
May 9 '07 #4
Scripsit Keith Clark:
I want to define a text style class which is active whenever I refer
to it. The following does not work

in CSS:
bluetext { COLOR: blue; FONT-SIZE:16px; }
In addition to using wrong syntax, it is all wrong in all points, including
a clueless class name, clueless color (using default link color for
something that isn't a link), cluelessly setting color without setting
background, and clueless unit for font size.

So stop right now. Don't dig any deeper. Get a decent book on web authoring
and read it.

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

May 9 '07 #5
On 9 May, 09:59, k.cl...@lucent.com (Keith Clark) wrote:
I want to define a text style class
Actually you need to define a "CSS selector", which will probably make
use of a HTML class.
which is active whenever I refer to it.
You can't do (exactly) that in CSS. It can take its place in the
queue, but all the rules are always evaluated and anything might
possibly get applied, according to the cascade and specificity rules.
You can make a strong selector, but it still might get outweighed
later. Nothing is provable unless you know both the CSS and the HTML -
you can't write an "absolute and forever" rule in CSS alone.

For your purposes though, this class is probably going to do what you
need.
in CSS:
bluetext { COLOR: blue; FONT-SIZE:16px; }
Try using .bluetext instead. Bare names are element names, those with
a leading period apply to classes, those with a leading hash to id
values.


May 9 '07 #6
Keith Clark wrote:
I want to define a text style class which is active whenever I refer to it.
The following does not work

in CSS:
bluetext { COLOR: blue; FONT-SIZE:16px; }
Firstly to specify a CLASS in your stylesheet you must prefix the class
name with a "."

..bluetext { COLOR: blue; FONT-SIZE:16px; }
>
in HTML:
....
<TABLE><TR><TD>
<class=bluetext>this should appear in blue</class>
</TD>
<TDThis should appear in some other style</TD>
...

Because there is no CLASS *element* in HTML, but a CLASS *attribute*
<table>
<tr>
<td class="bluetext">this will appear in blue</td>
<td>This will appear in whatever is your default style</tr>


--
Take care,

Jonathan
-------------------
LITTLE WORKS STUDIO
http://www.LittleWorksStudio.com
May 9 '07 #7
Gazing into my crystal ball I observed k.*****@lucent.com (Keith Clark)
writing in news:46**********************@newsspool2.arcor-online.net:
in CSS:
bluetext { COLOR: blue; FONT-SIZE:16px; }
That should be .bluetext - please note the leading period
Please don't use pixels for font sizing, it can't be adjusted by some
browsers.
>
in HTML:
....
<TABLE><TR><TD>
<class=bluetext>this should appear in blue</class>
</TD>
<TDThis should appear in some other style</TD>
...
That doesn't look like tabular data, but, anyway,
<p class="bluetext">This is blue text</por <p>This is regular text and
this <span class="bluetext">text is blue</span>.</p>

--
Adrienne Boswell at Home
Arbpen Web Site Design Services
http://www.cavalcade-of-coding.info
Please respond to the group so others can share

May 9 '07 #8
Keith Clark wrote:
I want to define a text style class which is active whenever I refer to it.
The following does not work

in CSS:
bluetext { COLOR: blue; FONT-SIZE:16px; }
Learn CSS.
To define a class selector use the correct syntax:
..bluetext { ... }
in HTML:
<class=bluetext>this should appear in blue</class>
There is no such tag as <class>. Learn HTML.
>
<P class=bluetext>this should appear in blue</P>
<TDThis should appear in some other style</TD>
This would work had you defined the rule correctly.

--
jmm (hyphen) list (at) sohnen-moe (dot) com
(Remove .AXSPAMGN for email)
May 9 '07 #9
Also sprach Keith Clark:
bluetext { COLOR: blue; FONT-SIZE:16px; }
This would refer to a <bluetextelement which, of course, does not exist.
To refer to elements of the *class* named "bluetext" you must write

..bluetext { ... }

Note the preceding dot!

By the way, it is better to choose a class name that conveys some meaning
rather than describing the appearance. For example,

..warning { color: red; font-weight: bold; }

clearly says what it means - a warning -, while

..redBoldText { color: red; font-weight: bold; }

does not give any hint as to *why* this text should be red and bold.
Suppose, you use your .bluetext class and someday you decide that the blue
text should be changed to a shade of green. Then you have two problems: 1)
You may have assigned the .bluetext class to other blue things as well which
should remain blue and not be changed. 2) It would look stupid if a class
called "bluetext" produced green text. So you should first ask yourself:
What is special about that particular piece of text? Why do you want it in a
different color? What does it represent? Is it a warning? Then call the
class "warning". Is it a definition? Then call the class "definition" etc.

Greetings,

Thomas
May 9 '07 #10
Keith Clark wrote:
I want to define a text style class which is active whenever I refer to it.
The following does not work

in CSS:
bluetext { COLOR: blue; FONT-SIZE:16px; }

in HTML:
....
<TABLE><TR><TD>
<class=bluetext>this should appear in blue</class>
</TD>
<TDThis should appear in some other style</TD>
...

Even when I encapsulate it in a <Ptag it doesn't work

....
<TABLE><TR><TD>
<P class=bluetext>this should appear in blue</P>
</TD>
<TDThis should appear in some other style</TD>
...

Why ?

Is there another wway ?

Keith


In your first HTML example, you have CLASS as an element. It's an
attribute on another element. That is, you should have
<td class=bluetextwithout any </class>.

Some browsers might not recognize "blue" as a value for "color". Try
changing the CSS to
bluetext { COLOR: #0000FF; FONT-SIZE:16px; }

The absolute size for FONT-SIZE is a very bad idea. Specify a size
relative to the user's preferred size.

For the P element in your second HTML example, is it possible you have a
conflicting color CSS?

--

David E. Ross
<http://www.rossde.com/>.

Don't ask "Why is there road rage?" Instead, ask
"Why NOT Road Rage?" or "Why Is There No Such
Thing as Fast Enough?"
<http://www.rossde.com/roadrage.html>
May 10 '07 #11
On 05/09/2007 03:59 AM, Keith Clark wrote:
I want to define a text style class which is active whenever I refer to it.
The following does not work

in CSS:
bluetext { COLOR: blue; FONT-SIZE:16px; }

in HTML:
.....
<TABLE><TR><TD>
<class=bluetext>this should appear in blue</class>
</TD>
<TDThis should appear in some other style</TD>
....

Even when I encapsulate it in a <Ptag it doesn't work

.....
<TABLE><TR><TD>
<P class=bluetext>this should appear in blue</P>
</TD>
<TDThis should appear in some other style</TD>
....

Why ?

Is there another wway ?

Keith

Encapsulate the text within a P element, but don't forget that classes
in CSS must start with a period:

In CSS:
..bluetext { COLOR: blue; FONT-SIZE:16px; }

May 10 '07 #12
Scripsit David E. Ross:
Some browsers might not recognize "blue" as a value for "color".
It would be a seriously broken browser, so it could just as well fail to
recognize any alternative denotation. We don't need to care about such
issues. There are good reasons to consider using #00f or #0000ff instead of
blue, but lack of support to this color name (which has been there ever
since the web turned into colors) is not one of them.

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

May 10 '07 #13
Keith Clark wrote:
I want to define a text style class which is active whenever I refer to it.
The following does not work

in CSS:
bluetext { COLOR: blue; FONT-SIZE:16px; }

in HTML:
....
<TABLE><TR><TD>
<class=bluetext>this should appear in blue</class>
</TD>
<TDThis should appear in some other style</TD>
...

Even when I encapsulate it in a <Ptag it doesn't work

....
<TABLE><TR><TD>
<P class=bluetext>this should appear in blue</P>
</TD>
<TDThis should appear in some other style</TD>
...

Why ?
Your CSS is wrong. To refer to a class, use the syntax
ELEMENT.class {...}
or
.class {...}

--
David
Stardate 7363.7
May 13 '07 #14
Keith Clark wrote:
I want to define a text style class which is active whenever I refer
to it. The following does not work

in CSS: bluetext { COLOR: blue; FONT-SIZE:16px; }
This is amusing. So far ten people have responded over four days to let
you know that you need a dot in front of the word 'bluetext', and you
haven't responded to any of them.

Maybe it is more amusing that ten people responded with the same answer.
:-)

--
-bts
-Motorcycles defy gravity; cars just suck
May 13 '07 #15

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Zeke Koos | last post: by
1 post views Thread by Mr.Clean | last post: by
reply views Thread by Keith Clark | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.