CSS Selected Contents

F

freesoft_2000

Hi everyone,

I have this rather silly question which i am not able to do
via CSS.

When i use the font tags i am able to apply the font to a
selected content say in a particular paragraph, but i don't seem to be
able to do this in CSS. Am i missing something.

A simple example of how to apply any font to selected
content in a paragraph using CSS would really be helpful.

Any help is greatly appreciated

Thank You

Yours Sincerely

Richard West
 
J

Jonathan N. Little

freesoft_2000 said:
Hi everyone,

I have this rather silly question which i am not able to do
via CSS.

When i use the font tags i am able to apply the font to a
selected content say in a particular paragraph, but i don't seem to be
able to do this in CSS. Am i missing something.

A simple example of how to apply any font to selected
content in a paragraph using CSS would really be helpful.

Any help is greatly appreciated

http://htmldog.com/guides/cssbeginner/
CSS Beginner's Guide - HTML Dog
 
R

richard

freesoft_2000 said:
Hi everyone,

I have this rather silly question which i am not able to do
via CSS.

When i use the font tags i am able to apply the font to a
selected content say in a particular paragraph, but i don't seem to be
able to do this in CSS. Am i missing something.

A simple example of how to apply any font to selected
content in a paragraph using CSS would really be helpful.

Any help is greatly appreciated

Thank You

Yours Sincerely

Richard West

You might want to use <span>.

<div class="atext">hello this is just a sample <span class="btext"> of what
you can do with css</span> blah blah blah blah blah</div>

Defining fonts and colors for each class as desired.
But research is always good. Even if you think you know it all.
 
F

freesoft_2000

Hi everyone,

Jonathan, your example in the link makes the entire
paragraph have the entire font whereas i only want part of the paragraph
to have that font and the rest of the paragraph not to have any font at
all.

Have i misunserstood your explanation in the link
somehow?

Any help is greatly appreciated

Thank You

Yours Sincerely

Richard West
 
B

Beauregard T. Shagnasty

freesoft_2000 said:
Jonathan, your example in the link makes the entire paragraph have the
entire font whereas i only want part of the paragraph to have that
font and the rest of the paragraph not to have any font at all.

"Selected content in a particular paragraph" is a bit vague if you meant
only a couple of words within a paragraph. It could have meant one
paragraph of many.

CSS:
..oddfont {
font-family: Georgia, serif;
}

HTML:
<p>Here is a long paragraph with only
<span class="oddfont">these words</span>
shown in the odd font.</p>
 
J

Jonathan N. Little

freesoft_2000 said:
Hi everyone,

Jonathan, your example in the link makes the entire
paragraph have the entire font whereas i only want part of the paragraph
to have that font and the rest of the paragraph not to have any font at
all.

Have i misunserstood your explanation in the link
somehow?

Any help is greatly appreciated

I guess you do not go through the whole tutorial. You can style
individual ELEMENTs so all you have to enclose the text your want to
style differently and enclose in an inline ELEMENT. Now how and which
element depends on the semantic "function' of the text. If you just want
to emphasize text well EM would work.

<p>Are your <em>sure</em> you want to emphasize this?</p>

Now browser normally style EM as italic, but you can change this within
your stylesheet

EM { font-style: normal; color: red; background-color: white; }

This would make every instance in your document where your surround text
with EM tags as red text instead if italic. If you do not wish to change
all the EMs your can specify a class:

..classy { font-family: "bernardfashion bt", fantasy; }

<p>Now my <em class="classy">emphasize</em> will be extra fancy!</p>

If it just a special word or phrase that you want to single out whell
your can us a SPAN element with a class:

..partnumber {
font-family: courier, "courier new", monospace;
font-weight: bold; color: blue; background-color: white;
}


<p>The Widgetmaster 5000 <span class="partnumber">PN: 2344-4322</span>
is a marvel of engineering....</p>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top