SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Zealot
    Join Date
    Jan 2005
    Location
    Mars
    Posts
    139
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Applying CSS To Selected HTML Contents

    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

  2. #2
    SitePoint Addict Sojan80's Avatar
    Join Date
    May 2002
    Location
    Central WI, US
    Posts
    262
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It's super simple.. just use a class... here's the CSS

    p.speacial {font-family: Georgia, Courier, Serif; color: teal, font-weight: bold;}

    in the HTML it would just be:

    <p class="special">Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean sit amet eros. In hac habitasse platea dictumst. Morbi commodo consectetuer felis. Aenean tristique pulvinar nisi. Maecenas ipsum. Curabitur scelerisque. Fusce euismod. Nullam tristique justo. Vestibulum nec sem facilisis nibh aliquet ornare. Sed ullamcorper suscipit augue. Pellentesque non metus. Praesent tellus sapien, gravida molestie, venenatis quis, varius ut, quam. Quisque est enim, mollis sit amet, aliquam in, scelerisque quis, libero. Integer arcu. Maecenas luctus massa ut neque. Curabitur ac lacus quis neque hendrerit commodo. Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aliquam quis metus. Morbi vestibulum pellentesque lorem. Etiam at purus.</p>

    You can name your class anything you want.... just so itm akes sense to you.

  3. #3
    SitePoint Zealot
    Join Date
    Jan 2005
    Location
    Mars
    Posts
    139
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question

    Hi everyone,

    Sojan80, would your example seems to make 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 somehow?

    Any help is greatly appreciated

    Thank You

    Yours Sincerely

    Richard West

  4. #4
    SitePoint Addict Sojan80's Avatar
    Join Date
    May 2002
    Location
    Central WI, US
    Posts
    262
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yep it would... but if you only wanted it to apply to say one word or a phrase then you would use a <span class="special">Just these words are affected</span> as a span is an inline element and not a block level element like <p></p>

    Just change the style rule to span.foo instead of p.foo


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •