Thread: CSS question

    #1
  1. No Profile Picture
    PHP-addict
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2001
    Location
    Netherlands
    Posts
    54
    Rep Power
    14

    CSS question


    I'm trying to master the art of CSS, so I was examining a stylesheet. Most of it seems pretty obvious, but the are two things I don't get:
    1. What does these lines mean:
    Code:
    .Content>p {margin:0px;}
    .Content>p+p {text-indent:30px;}
    2. What is the difference between a class and an id ?
    For instance: <div id=menu> or <div class=menu>

    Hope somebody can help me,

    Thanks,

    Ronald
    "Yes dear, I'll come to bed in a minute"
    R. Smit
    http://www.rsdev.nl
  2. #2
  3. Contributing User
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Oct 2001
    Location
    New Zealand
    Posts
    1,774
    Rep Power
    24
    An ID is a handle for that tag between it's opening and closing tags. Any JavaScript/CSS reference to that handle is applicable to the tags given that ID. A class on the other hand is defined inside the CSS style tags. A class is used when two or more items on a page display similar attributes (such as <p>, <h2> etc where you want all fonts to be black and 10pt and italic for example).

    I don't know what the p and p+p means on the other bit. Never seen it before, but the .content is similar to having a.whiteLink where a is for the anchor tag and .whiteLink is the whiteLink class.
  4. #3
  5. No Profile Picture
    Beelzebub
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2001
    Location
    The nether regions...ok, San Diego
    Posts
    164
    Rep Power
    13
    I've never seen any descriptors like that...seems like a typo.

    Just to add to binky's explanation...

    An ID is used for more than CSS, its a handle for that element in JavaScript as well. Its intended to be a unique identifier. If you give more than one element the same ID, the script associated with that element won't work. Of course you can assign CSS rules to it like this...
    #id_name {position: absolute.....}

    A class is only used in CSS and can be applied to any element, as many as you like....

    .class_name {color: blue}
    a.red {color: red}

    CSS doesn't care if you define an ID or class the same way.

    Happy Coding!

IMN logo majestic logo threadwatch logo seochat tools logo