๐ŸŽจ CSS Dictionary

Every keyword, operator, and symbol โ€” with plain-English explanations.

class selectors
A class selector is used to select elements with a specific class name.
.css{.my-class{color:red;}}
id selectors
An ID selector is used to select the element with a specific ID.
.css#{#my-element{color:red;}}
element selectors
An element selector selects all elements with a specific tag name.
.css{div{color:red;}}
pseudo-class selectors
A pseudo-class is used to select elements based on their state.
.css{a:hover{color:red;}}
pseudo-element selectors
A pseudo-element is used to select a part of an element.
.css{div::before{content:"Hello, ";}}
margin box-model
The margin property sets the space outside of an element's border.
.css{div{margin:20px;}}
padding box-model
The padding property sets the space inside an element's border.
.css{div{padding:20px;}}
border box-model
The border property sets all border properties in one declaration.
.css{div{border:1px solid black;}}
width box-model
The width property sets the width of an element.
.css{div{width:200px;}}
height box-model
The height property sets the height of an element.
.css{div{height:200px;}}
font-size typography
The font-size property sets the size of the font text.
.css{div{font-size:16px;}}
font-weight typography
The font-weight property sets the font weight of the text.
.css{div{font-weight:bold;}}
color colors
The color property sets the text color of the element.
.css{div{color:red;}}
background colors
The background property sets the background color of the element.
.css{div{background-color:blue;}}
display layout
The display property sets the display of the element.
.css{div{display:block;}}
position layout
The position property sets the type of positioning method used for an element.
.css{div{position:absolute;}}
float layout
The float property specifies how an element is to be moved around certain other elements.
.css{div{float:left;}}
z-index layout
The z-index property sets the z-position of an element.
.css{div{z-index:2;}}
flex flexbox
The flex property is a shorthand property for setting the flex-grow, flex-shrink and flex-basis properties.
.css{div{flex:1 1 auto;}}
grid-template grid
The grid-template property is a shorthand property for setting the grid-template-rows, grid-template-columns and grid-template-areas properties.
.css{div{grid-template:100px / 1fr 2fr;}}
@media media-queries
The @media rule is used to apply CSS rules when a specified condition for the external environment applies.
.css{@media (max-width: 600px) {div{width:100%;}}}
@keyframes animations
The @keyframes rule is used to define the style of an animation at certain points in time.
.css{@keyframes fadeIn {0% {opacity:0;} 100% {opacity:1;}}}
transition animations
The transition property is a shorthand property for the transition-* properties.
.css{div{transition:opacity 2s;}}
transform animations
The transform property is used to rotate, scale, skew, or translate an element.
.css{div{transform:rotate(45deg);}}
:hover selectors
The :hover pseudo-class represents an element when the mouse pointer is pointing at it or when the element has focus and is being hovered over.
.css{div:hover{color:red;}}
:focus selectors
The :focus pseudo-class represents an element when it has focus.
.css{div:focus{outline:2px solid red;}}
::before pseudo-element
The ::before pseudo-element is used to insert content before the content of an element.
.css{div::before{content:"Hello, ";}}
::after pseudo-element
The ::after pseudo-element is used to insert content after the content of an element.
.css{div::after{content:" world!";}}
var() variables
The var() function returns the value of a custom property (a CSS variable).
.css{--my-color: red;div{color:var(--my-color);}}
calc() variables
The calc() function performs arithmetic on CSS values and returns the result of that arithmetic.
.css{div{width:calc(100% - 20px);}}
rem variables
The rem unit is a relative length unit in CSS that is relative to the root element's font-size.
.css{div{font-size:2rem;}}
em variables
The em unit is a relative length unit in CSS that is relative to the font-size of the element itself.
.css{div{font-size:2em;}}
vh variables
The vh unit is a relative length unit in CSS that is relative to 1% of the viewport's height.
.css{div{height:50vh;}}
vw variables
The vw unit is a relative length unit in CSS that is relative to 1% of the viewport's width.
.css{div{width:50vw;}}
rgba colors
The rgba() function is used to define a color with an alpha (transparency) value.
.css{div{color:rgba(255,0,0,0.5);}}
opacity colors
The opacity property sets the transparency of an element.
.css{div{opacity:0.5;}}
overflow layout
The overflow property specifies what happens if an element's content is too big to fit in its block formatting context.
.css{div{overflow:auto;}}
box-shadow layout
The box-shadow property adds shadow effects to an element.
.css{div{box-shadow:2px 2px 5px black;}}
text-align typography
The text-align property sets the horizontal alignment of the text inside the element.
.css{div{text-align:center;}}
line-height typography
The line-height property sets the height of a line of text, relative to the font size of the element.
.css{div{line-height:1.5;}}