CSS Selectors Flashcards
CSS
Cascading Style Sheets
comments
/(asterisk) (asterisk)/
external style sheet linking syntax
Link Href="..." Rel="stylesheet" type="text/css" Media="all" /link
element selector
E
universal selector
*
class selector
.class
Id selector
id
targeting a specific element with a class
E.class
grouping multiple selectors
E, F, G
descendant selector (does not need to be a direct child)
E (space) F
negation selector
E:not(x)
direct child selectors
E > F
immediate adjacent selector
E + F
immediate predecessor selector
E ~ F
selects all elements with the attribute
[attribute]
selects all elements with the attribute value
[attribute=”value”]
element whose attribute value is a list of whitespace-separated values, one of which is exactly equal to “value”
E[attribute~=”value”]
element whose attribute value begins with exactly the string”value”
E[attribute^=”value”]
element whose attribute value ends with exactly the string “value”
E[attribute$=”value”]
element whose attribute value has the substring “value” in it at all
E[attribute*=”value”]
element whose attribute value has hyphen seperated text including the string “value”
E[attribute|=”value”]
not yet visited link
a:link
visited link
a:visited
active link (during certain user actions)
a:active
link hover
a:hover
element being targeted with an anchor
E:target
element in focus
E:focus
element with the specified language
E:lang(en)
element with no children
E:empty
enable element
E:enabled
disabled element
E:disabled
checked element (checkbox)
E:checked
generated content before an element
E::before
generated content after an element
E::after
targets the portion of the element selected by the user
::selected
the first child of this type in its parent
E:first-child
first formatted text line selector
E:first-line
first formatted letter selector
E:first-letter
first child of that element type
E:first-of-type
the last child of this type that is also the last element in its parent
E:last-child
the last child of this type in its parent
E:last-of-type
selects every element that is the only element of its type in its parent
E:only-of-type
the nth child of parent
E:nth-child(x)
nth child- custom repetition
E:nth-child(2x)
nth child- counting up instead
E:nth-child(-2x)
nth child- starting at a custom start point
E:nth-child(x+5)
nth child- start point is negative from the repetition (starts at 3)
E:nth-child(5x-2)
nth child- odd
E:nth-child(odd)
nth child- even
E:nth-child(even)
nth child- counting from the bottom
E:nth-last-child(x)
the nth child of this elements type
E:nth-of-type(x)
the nth child of this element type counting from the last one
E:nth-last-of-type(x)
input element with the “required” attribute active
input:required
input element with no “required” attribute
input:optional
input element with a value outside a specified range
input:out-of-range
input element with the “readonly” attribute specified
input:read-only
input element with NO “readonly” attribute specified
input:read-write
input element with a valid value in its field
input:valid