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?
| SitePoint Sponsor |


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?


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).
Save the Internet - Use Opera | May my mother rest in peace: 1943-2009
Dan Schulz - Design Team Advisor | Follow me on Twitter
SitePoint References: HTML CSS JavaScript | Become A Guru
WordPress SEO Checklist | What WordPress Plugins Do You Use?
Web Standards Curriculum | Image Free Equal Height Columns


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