CSS Selected Contents

Discussion in 'HTML' started by freesoft_2000, Sep 22, 2006.

  1. 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
     
    freesoft_2000, Sep 22, 2006
    #1
    1. Advertising

  2. freesoft_2000 wrote:
    > 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

    --
    Take care,

    Jonathan
    -------------------
    LITTLE WORKS STUDIO
    http://www.LittleWorksStudio.com
     
    Jonathan N. Little, Sep 22, 2006
    #2
    1. Advertising

  3. freesoft_2000

    richard Guest

    "freesoft_2000" <> wrote in message
    news:...
    > 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.
     
    richard, Sep 22, 2006
    #3
  4. 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
     
    freesoft_2000, Sep 22, 2006
    #4
  5. freesoft_2000 wrote:

    > 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>

    --
    -bts
    -Motorcycles defy gravity; cars just suck.
     
    Beauregard T. Shagnasty, Sep 22, 2006
    #5
  6. freesoft_2000 wrote:
    > 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>



    --
    Take care,

    Jonathan
    -------------------
    LITTLE WORKS STUDIO
    http://www.LittleWorksStudio.com
     
    Jonathan N. Little, Sep 22, 2006
    #6
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    3
    Views:
    490
  2. Don Adams
    Replies:
    1
    Views:
    625
    Martin Honnen
    Mar 5, 2004
  3. Ted
    Replies:
    0
    Views:
    153
  4. Kamarulnizam Rahim
    Replies:
    4
    Views:
    246
    Robert Klemme
    Jan 28, 2011
  5. Replies:
    0
    Views:
    217
Loading...

Share This Page