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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to apply CSS to text?

Status
Not open for further replies.

may1hem

Programmer
Jul 28, 2002
262
GB
At the moment, when I want to apply a style to the text of an article, I am using a <TABLE> tag or an <A> tag around some text and adding a CLASS=&quot;myArticleText&quot; parameter to the tag.

I know this is cheating as I don't really want a table or a link. I just want to define the font & colour for the main text of an article. How can i do this?

Should I use a <P> tag and apply a CLASS parameter to that? Or is there a better way?

Thanks,
May
 
<p> would be the best way to go
or <div>
but stick with <p>
but actually the text is already in a cell right -- why not give that cell a class with the text format the way you want it [Hammer]
Nike Failed Slogans -- &quot;Just Don't Do It!&quot;
 
Try the <div> tag instead...
Like this: One more gone <div class=&quot;something&quot;>and then there were none</div> thought mrs.tinkle
The only thing is that when the <div> applies it will force the text to be on a new line...so the above example would look like this:
One more gone
and then there were none
thought mrs.tinkle I have not failed; I have merely found 100,000 different ways of not succeding...
 
Woah, thanks for the quick replies!

The text shouldn't be in a cell but I am putting it there as a fix to make the CSS work.

I guess the <P> tag will also force a new line or paragraph. Is there no &quot;proper&quot; way to change the CSS in the same line? Hmmm...

I guess I could carry on using an <A> tag and applying the CSS to that.

Any other ideas?

Thx,
May
 
Hi May, you could use <span> tags.

i.e.
<span class=&quot;myArticleText&quot;>Blah Blah Blah</span>... testing testing. More writing etc. More writing etc. More writing etc. More writing etc. <span class=&quot;myArticleText&quot;>Blah Blah Blah</span>

Using <span> tags you can change the font color & size etc and it won't force a line break.

Hope thats what your after.

Pete
 
Code:
<p></p>
is a paragraph, so it's going to do what paragraphs do, which is to break and new-line. You can modify the class of the
Code:
<p>
tag such that there is any space you wish between paragraphs, but they'll still be paragraphs.

If you want to monkey with your text all inline (without breaking the paragraph), then using the
Code:
<span></span>
tag is probably going to be your solution, unless you want to use the
Code:
<font>
tag, which would just be evil.

Hope that helps!

Cheers,
[monkey] Edward [monkey]

&quot;Cut a hole in the door. Hang a flap. Criminy, why didn't I think of this earlier?!&quot; -- inventor of the cat door
 
Thanks guys!

Aren't there issues related to using <SPAN> tags? I thought I read something about that a few months ago.

May
 
<span> Is indeed used to give style to a certain amount of text or items. It is a good idea to have <span style=&quot;CSS here&quot;> instead of using Div which are meant to provide boxed containers to put wherever we want on the screen. Gary Haran
 
This may sound dumb but why not just use the good ol' <font color=red>Hello</font><font color=blue>Code One</font>.

Maybe that would be better? I dont really understand what the heck you want to do, and why you want to use css to do that. Anyway there is my suggestion.

Hope it helps

Code One
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top