CSS Selectors Cheatsheet

Selector Example Description
#id #container Selects the element with id="container"
.class .header Selects the element with class="header"
element.class p.description Selects all <p> elements with class="description"
element, element div, p Selects all <p> elements and all <div> elements
element element div p Selects all <p> elements inside <div> elements
element+element div + p Selects the first <p> element that is placed immediately after <div> element
element>element div > p Selects all <p> elements where the parent is a <div> element
element1~element2 p ~ ul Selects every <ul> element that is preceded by a <p> element
:first-child p:first-child Selects every <p> element that is the first child of its parent
:last-child p:last-child Selects every <p> element that is the last child of its parent
:hover button:hover Selects the button on mouse hover
* * Selects all elements
[attribute] src Selects all elements with a src attribute
[attribute=value] [target="_blank"] Selects all elements with target="_blank"
::after p::after Insert something after the content of each <p> element
::before p::before Insert something before the content of each <p> element
:active a:active Selects the active link
:visited a:visited Selects all visited links
:link a:link Selects all unvisited links
:checked input:checked Selects every checked <input> element
:default input:default Selects the default <input> element
:disabled input:disabled Selects every disabled <input> element
:required input:required Selects input elements with the "required" attribute specified
:not(selector) :not(p) Selects every element that is not a <p> element
:last-of-type p:last-of-type Selects every <p> element that is the last <p> element of its parent
:first-of-type p:first-of-type Selects every <p> element that is the first <p> element of its parent

HTML Tags Cheatsheet

Tag Description
<!--...--> Defines a comment
<!DOCTYPE> Defines the document type
<a> Defines a hyperlink
<abbr> Defines an abbreviation or an acronym
<address> Defines contact information for the author/owner of a document
<area> Defines an area inside an image map
<article> Defines an article
<aside> Defines content aside from the page content
<audio> Defines embedded audio content
<b> Defines bold text
<blockquote> Defines a section that is quoted from another source
<br> Defines a single line break
<button> Defines a clickable button
<caption> Defines a table caption
<em> Defines emphasized text
<strong> Defines important text
<small> Defines smaller text
<select> Defines a dropdown list
<svg> Defines a container for SVG graphics
<label> Defines a label for an <input> element
<i> Defines a part of text in an alternate voice or mood