CSS Selector Reference

CSS Selector Reference


CSS Selector Reference
CSS Selectors allow us to target our HTML elements in order to style them with the CSS Properties. Selectors are patterns that target an HTML element by type, by class and id, hierarchal relationships of elements and pseudo-classes to supply us with a great deal of selection logic when styling our web documents. Each CSS level builds off of the previous level so you can apply all selectors.

CSS 1 Selectors

CSS1 SelectorSyntax and Code Examples
type selectorX { }
group selectorX, Y { }
descendant combinatorX Y { }
class selectorX.class { }
id selectorX#id { }
first-line selectorX::first-line { }
first-letter selectorX::first-letter { }
active SelctorX:active { }
hover selectorX:hover { }
link selectorX:link { }
visited selectorX:visited { }

CSS 2 Selectors

CSS2 SelectorSyntax and Code Examples
universal selector* { }
child combinatorX > Y { }
adjacent sibling combinatorX + Y { }
after selectorX::after { }
before selectorX::before { }
lang selectorX:lang { }
first-child selectorX:first-child { }
attribute selectorX[att] { }

CSS 3 Selectors

WARNING: You will notice that some CSS3 selectors WILL NOT WORK in all browsers yet. This is because CSS3 has not become a web standard yet and browser makers are slowly adding the new CSS3 modules to the various browsers. When CSS3 becomes a standard we will update our library to reflect that and remove any CSS3 warnings in place.
CSS3 SelectorSyntax and Code Examples
general sibling combinatorX ~ Y { }
not selectorX:not(Y) { }
target selectorX:target { }
enabled selectorX:enabled { }
disabled selectorX:disabled { }
checked selectorX:checked { }
root selectorX:root { }
nth-child selectorX:nth-child(N) { }
nth-last-child selectorX:nth-last-child(N) { }
nth-of-type selectorX:nth-of-type(N) { }
nth-last-of-type selectorX:nth-last-of-type(N) { }
last-child selectorX:last-child { }
first-of-type selectorX:first-of-type { }
last-of-type selectorX:last-of-type { }
only-child selectorX:only-child { }
only-of-type selectorX:only-of-type { }
empty selectorX:empty { }

0 Response to "CSS Selector Reference"

Post a Comment