SitePoint Sponsor

User Tag List

Results 1 to 6 of 6

Thread: Text in CSS

  1. #1
    Wishful Thinking webmasternovis's Avatar
    Join Date
    Jul 2002
    Location
    England
    Posts
    430
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Text in CSS

    Hi guys,

    At the moment I have a div:

    Code:
    <div class="class"></div>
    In that div I want some text in a specific font and colour, but don't know how to do that without using HTML tags - which I don't want to use.

    Does anyone know how I can get around my problem?

    Cheers,
    Mike

  2. #2
    ☆★☆★ silver trophy vgarcia's Avatar
    Join Date
    Jan 2002
    Location
    in transition
    Posts
    21,235
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    Put this in the <head></head> of your document:
    Code:
    <style type="text/css" media="screen">
    .class {
    font-family: verdana;
    font-size: 10pt;
    color: #006;
    }
    </style>
    You should get a 10pt dark blue verdana font in divs with a class of "class".

    Also, read up on CSS at http://www.w3schools.com/css/ to get a better understanding of what CSS can do.

  3. #3
    SitePoint Enthusiast abbey's Avatar
    Join Date
    Apr 2003
    Location
    Chicago
    Posts
    89
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    point is a print measurement, so you might not want to use that due to rendering differences across browsers/platforms.

    In addition to W3schools, another good tutorial on divs and so forth is at http://www.mako4css.com/Tutorial.htm
    <abbey />
    HTML/XHTML/CSS coding
    Abbey Ink

  4. #4
    ☆★☆★ silver trophy vgarcia's Avatar
    Join Date
    Jan 2002
    Location
    in transition
    Posts
    21,235
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by abbey
    point is a print measurement, so you might not want to use that due to rendering differences across browsers/platforms.
    True, pt is just something that a lot of people are used to seeing because of word processing/office programs. I didn't want to scare anybody with 0.8em or 80%, which is what I'd normally use.

  5. #5
    SitePoint Enthusiast abbey's Avatar
    Join Date
    Apr 2003
    Location
    Chicago
    Posts
    89
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Vinnie, I know what you mean -- I came out of a print background, so I could relate to points.

    Until I saw what could happen after reading this and similar sites. So, I guess I just wanted to save someone some grief.
    <abbey />
    HTML/XHTML/CSS coding
    Abbey Ink

  6. #6
    The CSS Clinic is open silver trophybronze trophy
    Paul O'B's Avatar
    Join Date
    Jan 2003
    Location
    Hampshire UK
    Posts
    40,295
    Mentioned
    179 Post(s)
    Tagged
    6 Thread(s)
    Hi,
    If Ican add to what Vinnie said without treading on anyone's toes.

    If you want some inline text to be different from the class that you've set then you can set up a span like this:

    Code:
    <style type="text/css">
    .test {
     color: red;
    }
    .test span {
     color: blue;
    }
    </style>
    And then in the body:
    Code:
    <div class="test">
    <p>this is red <span>this is blue</span> this is red</p>
    </div>
    The above code makes any spans in the class test turn to blue.

    I hope this is of some use.

    Paul


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
  •