SitePoint Sponsor

User Tag List

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

    noob: selector vs element

    I have googled and read docs on this. But don't understand what is the different between selector and an element. For me, both seem to be the same.

    Any insight?

  2. #2
    In memoriam gold trophysilver trophybronze trophy Dan Schulz's Avatar
    Join Date
    May 2006
    Location
    Aurora, Illinois
    Posts
    15,478
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    An element is an HTML construct that consists (most of the time) of an opening and closing tag and the content inside of it, such as <p>This is just the first sentence of a paragraph. Other content will follow this, but I am keeping this short so I do not bore you to death.</p>.

    A selector on the other hand is used by CSS to apply styles to those HTML elements. Selectors can also target classes (which can have the same value applied multiple times, like <img class="dogs" src="images/lassie.jpg" height="150" width='200" alt="border collie" title="Lassie, one of the most famous dogs in the world"> and <div class="dogs">content about dogs</div> - also note that the alt="" text was not optimized and may not be appropriate in this case) as well as IDs (which can have their value used only once so id="dogs" and id="dogs" cannot be used in the same HTML page).

  3. #3
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    A selector describes which elements a certain CSS rule should apply to. It's like a pattern: the rule will apply to all elements that match this pattern.

    A selector can be an element type,
    Code CSS:
    table {...}

    It can also be rather more complex, involving a hierarchy of elements, attributes, pseudo-classes and pseudo-elements:
    Code CSS:
    html>head+body table.foo[summary] th:first-child {...}
    Birnam wood is come to Dunsinane


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
  •