W3 Mind Logo
Home » CSS Selectors

CSS Selectors

CSS selectors are patterns used to select the element(s) you want to style.

Examples of some CSS selectors:

Selector Example
.class .intro
#id #firstname
* *
element p
element,element div, p
element element div p
element>element div > p
element+element div + p
element1~element2 p ~ ul
[attribute] [target]
[attribute=value] [target=_blank]
[attribute~=value] [title~=flower]
[attribute|=value] [lang|=en]
[attribute^=value] a[href^=”https”]
[attribute$=value] a[href$=”.pdf”]
[attribute*=value] a[href*=”w3schools”]
:active a:active
::after p::after
::before p::before
:checked input:checked
:disabled input:disabled
:empty p:empty
:enabled input:enabled
:first-child p:first-child
::first-letter p::first-letter
::first-line p::first-line
:first-of-type p:first-of-type
:focus input:focus
:hover a:hover
:in-range input:in-range
:invalid input:invalid
:lang(language) p:lang(it)
:last-child p:last-child
:last-of-type p:last-of-type
:link a:link
:not(selector) :not(p)
:nth-child(n) p:nth-child(2)
:nth-last-child(n) p:nth-last-child(2)
:nth-last-of-type(n) p:nth-last-of-type(2)
:nth-of-type(n) p:nth-of-type(2)
:only-of-type p:only-of-type
:only-child p:only-child
:optional input:optional
:out-of-range input:out-of-range
:read-only input:read-only
:read-write input:read-write
:required input:required
:root :root
::selection ::selection
:target #news:target
:valid input:valid
:visited a:visited
About Author
Picture of W3Mind

W3Mind

W3Mind focuses on Blogging, Make Money Online, SEO, Business Blogging, Social Media, WordPress, Internet Tools, Web Design and Development.
Give it a Share
Facebook
Twitter
LinkedIn
You May Also Like
How to
START A
BLOG
(step by step)
Load WordPress Sites in as fast as 37ms!