SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Thread: Little question

  1. #1
    Non-Member Siltrince's Avatar
    Join Date
    Aug 2001
    Location
    Belgium
    Posts
    304
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Little question

    Hi,
    I had just a little question about CSS.
    I write my CSS allways like this:

    <style>

    Body {
    background-color: #00000;
    ...
    }

    .MaincontentDIV {
    background-color: #111111;
    ...
    }
    </style>

    *********************************************************
    But i've noticed a lot of people writting their CSS like this:

    <style>

    Body {
    background-color: #00000;
    ...
    }

    DIV.MaincontentDIV {
    background-color: #111111;
    ...
    }
    </style>


    Is my way wrong or is the other way better for any reaon ?
    Thx in advance.

  2. #2
    SitePoint Wizard
    Join Date
    Jul 2001
    Location
    The Netherlands
    Posts
    2,617
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Both are correct ways of writing CSS. They just have different endresults. For example if I take this code:

    Code:
    .something {
    font-family: Comic Sans MS;
    }
    That would make every HTML element which got the attribute class="something" be displayed in Comic Sans MS.
    However, would I use this code:

    Code:
    p.something {
    font-family: Comic Sans MS;
    }
    Then all the code that would be written with class="something" would be displayed as it would by default, with the exception for <p> tags.

    So the difference is that when you add something before the period, the class only becomes applicable to that particular element in HTML.

  3. #3
    Non-Member Siltrince's Avatar
    Join Date
    Aug 2001
    Location
    Belgium
    Posts
    304
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Thumbs up

    Ok thanks for the fast answer Mark


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
  •