Monday, October 29, 2012

CSS ... Selectors to be learned

SelectorExampleExample descriptionSince CSS versionSupported in
.class.introSelects all elements with class="intro"1 IE6+ Firefox Chrome Safari Opera
#id#firstnameSelects the element with id="firstname"1 IE6+ Firefox Chrome Safari Opera
**Selects all elements2 IE6+ Firefox Chrome Safari Opera
elementpSelects all elements1 IE6+ Firefox Chrome Safari Opera
element,elementdiv,pSelects all
elements and all elements
1 IE6+ Firefox Chrome Safari Opera
element elementdiv pSelects all elements inside
elements
1 IE6+ Firefox Chrome Safari Opera
element>elementdiv>pSelects all elements where the parent is a
element
2 IE6+ Firefox Chrome Safari Opera
element+elementdiv+pSelects all elements that are placed immediately after
elements
2 IE6+ Firefox Chrome Safari Opera
[attribute][target]Selects all elements with a target attribute2 IE6+ Firefox Chrome Safari Opera
[attribute=value][target=_blank]Selects all elements with target="_blank"2 IE6+ Firefox Chrome Safari Opera
[attribute~=value][title~=flower]Selects all elements with a title attribute containing the word "flower"2 IE6+ Firefox Chrome Safari Opera
[attribute|=value][lang|=en]Selects all elements with a lang attribute value starting with "en"2 IE6+ Firefox Chrome Safari Opera
:linka:linkSelects all unvisited links1 IE6+ Firefox Chrome Safari Opera
:visiteda:visitedSelects all visited links1 IE6+ Firefox Chrome Safari Opera
:activea:activeSelects the active link1 IE6+ Firefox Chrome Safari Opera
:hovera:hoverSelects links on mouse over1 IE7+ Firefox Chrome Safari Opera
:focusinput:focusSelects the input element which has focus2 IE8+ Firefox Chrome Safari Opera
:first-letterp:first-letterSelects the first letter of every element1 IE8+ Firefox Chrome Safari Opera
:first-linep:first-lineSelects the first line of every element1 IE8+ Firefox Chrome Safari Opera
:first-childp:first-childSelects every element that is the first child of its parent2 IE8+ Firefox Chrome Safari Opera
:beforep:beforeInsert content before the content of every element2 IE7+ Firefox Chrome Safari Opera
:afterp:afterInsert content after every element2 IE7+ Firefox Chrome Safari Opera
:lang(language)p:lang(it)Selects every element with a lang attribute value starting with "it"2 IE8+ Firefox Chrome Safari Opera
element1~element2p~ulSelects every
    element that are preceded by a element
3 IE8+ Firefox Chrome Safari Opera
[attribute^=value]a[src^="https"]Selects every element whose src attribute value begins with "https"3 IE8+ Firefox Chrome Safari Opera
[attribute$=value]a[src$=".pdf"]Selects every element whose src attribute value ends with ".pdf"3 IE8+ Firefox Chrome Safari Opera
[attribute*=value]a[src*="coffee"]Selects every element whose src attribute value contains the substring "coffee"3 IE8+ Firefox Chrome Safari Opera
:first-of-typep:first-of-typeSelects every element that is the first element of its parent3 IE8+ Firefox Chrome Safari Opera
:last-of-typep:last-of-typeSelects every element that is the last element of its parent3 IE8+ Firefox Chrome Safari Opera
:only-of-typep:only-of-typeSelects every element that is the only element of its parent3 IE8+ Firefox Chrome Safari Opera
:only-childp:only-childSelects every element that is the only child of its parent3 IE8+ Firefox Chrome Safari Opera
:nth-child(n)p:nth-child(2)Selects every element that is the second child of its parent3 IE8+ Firefox Chrome Safari Opera
:nth-last-child(n)p:nth-last-child(2)Selects every element that is the second child of its parent, counting from the last child3 IE8+ Firefox Chrome Safari Opera
:nth-of-type(n)p:nth-of-type(2)Selects every element that is the second element of its parent3 IE8+ Firefox Chrome Safari Opera
:nth-last-of-type(n)p:nth-last-of-type(2)Selects every element that is the second element of its parent, counting from the last child3 IE8+ Firefox Chrome Safari Opera
:last-childp:last-childSelects every element that is the last child of its parent3 IE8+ Firefox Chrome Safari Opera
:root:rootSelects the document’s root element3 IE9+ Firefox Chrome Safari Opera
:emptyp:emptySelects every element that has no children (including text nodes)3 IE9+ Firefox3+ Chrome Safari Opera
:target#news:target Selects the current active #news element (clicked on a URL containing that anchor name)3 IE8+ Firefox Chrome Safari Opera
:enabledinput:enabledSelects every enabled input element3 IE9+ Firefox3+ Chrome Safari Opera
:disabledinput:disabledSelects every disabled input element3 IE9+ Firefox3+ Chrome Safari Opera
:checkedinput:checkedSelects every checked input element3 IE9+ Firefox3+ Chrome Safari Opera
:not(selector):not(p)Selects every element that is not a element3 IE9+ Firefox Chrome Safari Opera
::selection::selectionSelects the portion of an element that is selected by a user3 IE6+ Firefox Chrome Safari Opera

Selecting the selectors. -S