๐จ CSS Dictionary
Every keyword, operator, and symbol โ with plain-English explanations.
class selectorsA class selector is used to select elements with a specific class name.
.css{.my-class{color:red;}}id selectorsAn ID selector is used to select the element with a specific ID.
.css#{#my-element{color:red;}}element selectorsAn element selector selects all elements with a specific tag name.
.css{div{color:red;}}pseudo-class selectorsA pseudo-class is used to select elements based on their state.
.css{a:hover{color:red;}}pseudo-element selectorsA pseudo-element is used to select a part of an element.
.css{div::before{content:"Hello, ";}}margin box-modelThe margin property sets the space outside of an element's border.
.css{div{margin:20px;}}padding box-modelThe padding property sets the space inside an element's border.
.css{div{padding:20px;}}border box-modelThe border property sets all border properties in one declaration.
.css{div{border:1px solid black;}}width box-modelThe width property sets the width of an element.
.css{div{width:200px;}}height box-modelThe height property sets the height of an element.
.css{div{height:200px;}}font-size typographyThe font-size property sets the size of the font text.
.css{div{font-size:16px;}}font-weight typographyThe font-weight property sets the font weight of the text.
.css{div{font-weight:bold;}}color colorsThe color property sets the text color of the element.
.css{div{color:red;}}background colorsThe background property sets the background color of the element.
.css{div{background-color:blue;}}display layoutThe display property sets the display of the element.
.css{div{display:block;}}position layoutThe position property sets the type of positioning method used for an element.
.css{div{position:absolute;}}float layoutThe float property specifies how an element is to be moved around certain other elements.
.css{div{float:left;}}z-index layoutThe z-index property sets the z-position of an element.
.css{div{z-index:2;}}flex flexboxThe 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 gridThe 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-queriesThe @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 animationsThe @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 animationsThe transition property is a shorthand property for the transition-* properties.
.css{div{transition:opacity 2s;}}transform animationsThe transform property is used to rotate, scale, skew, or translate an element.
.css{div{transform:rotate(45deg);}}:hover selectorsThe :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 selectorsThe :focus pseudo-class represents an element when it has focus.
.css{div:focus{outline:2px solid red;}}::before pseudo-elementThe ::before pseudo-element is used to insert content before the content of an element.
.css{div::before{content:"Hello, ";}}::after pseudo-elementThe ::after pseudo-element is used to insert content after the content of an element.
.css{div::after{content:" world!";}}var() variablesThe var() function returns the value of a custom property (a CSS variable).
.css{--my-color: red;div{color:var(--my-color);}}calc() variablesThe calc() function performs arithmetic on CSS values and returns the result of that arithmetic.
.css{div{width:calc(100% - 20px);}}rem variablesThe 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 variablesThe 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 variablesThe vh unit is a relative length unit in CSS that is relative to 1% of the viewport's height.
.css{div{height:50vh;}}vw variablesThe vw unit is a relative length unit in CSS that is relative to 1% of the viewport's width.
.css{div{width:50vw;}}rgba colorsThe rgba() function is used to define a color with an alpha (transparency) value.
.css{div{color:rgba(255,0,0,0.5);}}opacity colorsThe opacity property sets the transparency of an element.
.css{div{opacity:0.5;}}overflow layoutThe 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 layoutThe box-shadow property adds shadow effects to an element.
.css{div{box-shadow:2px 2px 5px black;}}text-align typographyThe text-align property sets the horizontal alignment of the text inside the element.
.css{div{text-align:center;}}line-height typographyThe 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;}}