Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New Coder
    Join Date
    Feb 2009
    Posts
    48
    Thanks
    0
    Thanked 0 Times in 0 Posts

    div.whythefullstop

    Hey,

    I have been playing around with loads of css scripting? or coding? not sure which term to use, however i can't seem to understand why there is the need of the full stop after some of the div id's?

    such as div.ex does this select some other tag after the div id?

  • #2
    The fat guy next door VIPStephan's Avatar
    Join Date
    Jan 2006
    Location
    Halle (Saale), Germany
    Posts
    8,777
    Thanks
    6
    Thanked 1,021 Times in 994 Posts
    The period denotes a class selector, not ID.

    Code:
    #whatever {…}
    .whatever {…}
    Code:
    <div id="whatever"></div>
    <div class="whatever"></div>
    Two different things.
    But you can also combine both:
    Code:
    <div id="whatever1" class="whatever"></div>
    <div id="whatever2" class="whatever"></div>
    
    .whatever {…}
    .whatever#whatever1 {…}
    #whatever2.whatever {…}

  • #3
    New Coder
    Join Date
    Feb 2009
    Posts
    48
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thank you for your help, appreciate it.

    I need more practice in using id's and class.

  • #4
    The fat guy next door VIPStephan's Avatar
    Join Date
    Jan 2006
    Location
    Halle (Saale), Germany
    Posts
    8,777
    Thanks
    6
    Thanked 1,021 Times in 994 Posts
    Be aware that an ID must be unique in an HTML document, no more than one element can have a particular ID. Classes, however, can be assigned to multiple elements on the same page.

  • #5
    New Coder
    Join Date
    Feb 2009
    Posts
    48
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I guess an image is ideal for an id and a paragraph of text in numerous div's would be more suitable as a class.

  • #6
    The fat guy next door VIPStephan's Avatar
    Join Date
    Jan 2006
    Location
    Halle (Saale), Germany
    Posts
    8,777
    Thanks
    6
    Thanked 1,021 Times in 994 Posts
    There is no general rule for that, it all depends on the context. Sometimes you don’t need any class or ID at all as you can use the element or attribute selector (e. g. p img {…}, #content > img {…} or input[type=text] {…}).


  •  

    Posting Permissions

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