SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Addict
    Join Date
    Oct 2006
    Posts
    216
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Are these same: div.centre div .centre

    Are these same: div.centre div .centre? (note: space between div and .center and no space between div and .center)

  2. #2
    SitePoint Enthusiast
    Join Date
    Feb 2006
    Posts
    62
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    No, they are not the same:

    div.centre only affects divs that have a class of centre:

    Code:
    <div class="centre">this is affected</div>
    
    <!-- the following will not be affected by div.centre -->
    <p class="centre">this is not affected</p>
    However, div .centre affects *anything* that has a class of centre, that is also inside a div.:

    Code:
    <p class="centre">this not not be affected as it is not contained in a div.</p>
    
    <div class="centre">this is NOT affected by div. centre, it is not inside another div</div>
    
    <div><div class="centre">this IS affected because the element with a class of centre IS inside a div</div></div>
    
    <div><p class="centre">this is also affected</p></div>
    
    <div><a href="#" class="centre">this is affected, too</a></div>
    John


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
  •