• CSS stands for Cascading Style Sheets
  • CSS provides styling to the static HTML page
  • CSS introduced to replace the line-by-line styling attributes.
  • CSS executes at client-side on the browser
  • It is not a Programming language.

Animation-delay: Specifies the delay before an animation starts playing: animation-direction: Defines if the animation plays in reverse or alternate cycles: animation-duration: Sets the duration of an animation cycle: animation-fill-mode: Sets the style for an element while the animation is not active (finished or delayed) animation-iteration-count. Creating animation in CSS; Loader project; Let’s start. Animation properties. Setting an animation is done by assigning animate property while styling the element or its sub-properties. That’s why to start creating awesome animations in CSS, you have to know how you can set the duration, timing, delay, and some more.

Here we have provided the most common CSS cheat snippets which cover CSS gradient, background, button, font-family, border, radius, box and text-shadow generators, color picker and lots more.

CSS buzzwords.

  • CSS3
  • Bootstrap
  • Bootstrap4

CSS3 is the newest version of CSS which has many new features.

Bootstrap is an open-source framework of CSS, which is written on CSS3.

Bottstrap4 is the newest version of Bootstrap.

CSS Cheat Codes:

Basic CSS Cheat Codes:

TypeSyntax
Include external CSS file<link rel=”stylesheet” type=”text/css” href=”/file_name.css” />
selectorselector{

property1: value1;

property2: value2;

}

Internal Style CSS<style type=”text/css”>

class{ color: #444; }

</style>

Inline CSS<tag style=”property: value”> </tag>

Selectors

Selectors are the HTML tags or class names on which we want to apply styling.

Example

Here div is selector font-weight is property and bold is value.

Examples:

Selector SyntaxDescription
* {

}

To select all the tags
div {

}

To select all div tags
div,h1 {

}

To select all div and heading 1 tags
Div h2{

}

To select all heading 2 tags inside all div tags
div > h1{

}

All h1 tags one level deep in div
div + h1{

}

h1 tags immediately after div
div ~ h1{

}

h1 tags preceded by div
.classname{

}

all elements with class
div.classname{

}

divs with certain classname
div#id_name{

}

div with certain ID
#id_name *{

}

all elements inside #idname

Background

There are many CSS properties associated with the background of any tag.

Background Properties Accepting Values
background-imageURL or None
background-positionTop left, top right, center, bottom left, bottom right, bottom center

x-% y-%

x-po y-pos

background-sizeLength or auto
background-repeatRepeat or no repeat
background-attachmentScroll | fixed
background-breakBounding-box| each box| continuous
background-clipLength
background-originBorder-box or padding box or content box
background-colorColor or transparent

Example

Border:

There are many sub-properties associated with the border tag.

border Properties Accepting Values
border-colorColor
border-widthLength, thin, medium thick
border-styleNone, hidden, dotted dashed, solid, double, groove, ridge, inset, outset
border-imageImage
border-collapseCollapse, separate
border-left-colorColor
border-left-styleNone, hidden, dotted dashed, solid, double, groove, ridge, inset, outset
border-left-widthLength, thin, medium thick
border-bottom-styleNone, hidden, dotted dashed, solid, double, groove, ridge, inset, outset
border-bottom-colorColor
border-bottom-widthLength, thin, medium thick
border-right-colorColor
border-right-styleNone, hidden, dotted dashed, solid, double, groove, ridge, inset, outset
border-right-widthLength, thin, medium thick

Example:

Fonts:

The font deal with the writing style and size of the characters shown on the display here are some common font properties.

Animation
font Properties Accepting Values
font-styleitalic, oblique, normal
font-variantnormal, small-caps, inherit
font-weightbold, lighter, 100, 200, 300, inherit, normal
font-sizexx-small, x-small, small, large, length, %
font-familyGeneric-name, inherit, font-family name
font-size-adjustnone, inherit number
font-alignright, left, center, justify
font-transformCapitalize, uppercase, lowercase
font-stretchnormal, wider, narrower, extra-condensed, semi-condensed, inherit

Example:

Table

In HTML we often use table tag so here are some most common table properties used in CSS.

table Properties Accepting Values
border-collapsecollapse, separate
border-spacinglength
caption-sidetop, bottom, left, right
empty-cellsshow or hide
table-layoutauto or fixed
Animation

Example:

Animation

CSS help to animate the HTML elements without using JavaScript. Here are some important CSS Animations properties

Animation Properties Accepting Values
animation-delaytime
animation-directionnormal, alternate
animation-durationtime
animation-iteration-countinherit number
animation-paly-staterunning, paused
animation-namenone, ident
animation-timing-functionlinear, ease, ease-in, ease-out, cubic-bezier

Example:

Box Model

In HTML, every tag has its own box-like structure and all its content is limited to that box, the size of the box default depends upon the tag content size. With CSS Box model properties, we can style each tag box.

Box-Model Properties Accepting Values
widthlength, %
borderlength, %
marginauto, length, %
paddinglength, %
max-widthlength, %
min-widthlength, %
heightlength, %
min-heightlength, %
max-heightlength, %
margin-bottomlength, %
margin-leftlength, %
margin-rightlength, %
rotationangle
rotation-pointposition
visibilityvisible, hidden, collapse
displayinline, block, list-item, run-in, table, etc,
clearleft, right, none, both
overflowvisible, hidden, scroll, no-display, overflow-x, overflow-y
padding-rightlength, %
padding-toplength, %
padding-leftlength, %

Example:

Text

There are many CSS properties associated with the text we see on our webpages.

Text Properties Accepting Values
text-alignleft, center, justify, right, start, end
text-align-lastleft, center, justify, right, start, end
text-decorationunderline, overline, line-through, blink
text-emphasisenone, [[accent, dot, circle,] [before, after]]
text-indentlength, %
text-justifyauto, inter-word, inter-ideograph
text-outlinecolour, length
text-shadowcolor, length
text-transformcapitalize, uppercase, lowercase
text-wrapunrestricted, suppress
white-spacepre, nowrap, pre-wrap, pre-line
word-spacingnormal, length, %
word-wrapbreak-word
directionltr, rtr
hanging-punctuationstart, end, end-edge
letter-spacinglength, %
punctuation-trimstart, end, end-edge

Example:

Value Units

There are many types of values we provided to the properties such as color, length, angle, time etc here are some basic Value Unites present in CSS:

Length
UnitsDescription
%percentage
cmcentimetres
ininches
mmmillimeters
ptpoints 1pt = 1/72 inches
pcpica 1 pica = 12 points
Angle
Angle UnitsDescription
degdegrees
gradgrads
radradian
turnturns
Time
Time UnitsDescription
msmilli-seconds
Sseconds
Frequency
Frequency UnitsDescription
Hzhertz
Khzkilo-hz
Color
Typevalue
color namered, green, yellow, etc
rbg(x,y,z)red= rbg(255,0,0)
rbg(x%,y%,z%)red = rbg(100%,0,0)
#rrggbbred = #ff000
hsl(heu, saturation, lightness)red = hsl(0,100%,50%)
currentcolorput the value of currentcolor keyword

People Also Read:

A

align-contentPacks text lines to the left of the flex container
align-itemsSpecifies the default alignment for items inside a specific flex container
align-selfSpecifies the alignment for a selected item in a flex container
allResets all the properties to either inherited or initial value
animationA shorthand for the eight properties used for animation
animation-delaySpecifies the delay before an animation starts playing
animation-directionDefines if the animation plays in reverse or alternate cycles
animation-durationSets the duration of an animation cycle
animation-fill-modeSets the style for an element while the animation is not active (finished or delayed)
animation-iteration-countDefines the number of times an animation should normally repeat
animation-nameSpecifies the name of the animation
animation-timing-functionSpecifies the duration of time for an element to transition from one set of styles to another

B

backface-visibilityDefines if the element’s back is visible when it is not facing the screen
backgroundA shorthand for the eight properties used for background
background-clipSpecifies the area to which a background should extend
background-colorSets a background color
background-imageSets a background image for an element
background-originSpecifies where to position the background image
background-positionSpecifies the initial position of the background image
background-sizeDefines the size of the background image
borderA shorthand for the three properties used for borders
border-bottom-left-radiusDefines the rounded corners for an element
border-imageSpecifies the image to be used instead of a regular border
border-image-outsetSpecifies how much of the border image goes outside of the border box
border-image-repeatSpecifies if the border image is rounded, repeated or stretched
border-image-sliceSpecifies how a border image should be sliced
border-image-sourceSpecifies the path to access the image that you want to use as a border
border-image-widthSpecifies the border image width
border-radiusA shorthand for the four properties used for border radius
border-styleDefines the style of the border lines
border-top-left-radiusDefines the shape of the top left corner border
border-top-right-radiusDefines the shape of the top right corner border
border-bottom-left-radiusDefines the shape of the bottom left corner border
border-bottom-right-radiusDefines the shape of the bottom right corner border
box-shadowAdds a shadow to a box element
box-sizingSpecifies whether the height and width values represent the content box or the border box

C

colorSets the color of text
column-countSpecifies the number of columns an element should be divided into
column-gapDefines the gap between columns
column-ruleA shorthand for the three properties used for column rules
column-rule-colorSpecifies the color of the column rule
column-rule-styleSpecifies the style of the column rule
column-rule-widthSpecifies the width of of the column rule
column-spanSpecifies how many columns an element should span across
column-widthSpecifies the optimal width of a column
columnsA shorthand for column-width and column-count

D

displaySpecifies what kind of container the element will use

F

filterDefines visual effects for elements
flexA shorthand for flex-grow, flex-shrink and flex-basis
flex-basisSets the initial length of a flex item
flex-directionSpecifies the placement of flex items
flex-flowA shorthand for flex-direction and flex-wrap
flex-growSpecifies how much a flex item should grow when there's too much space in a flex container
flex-shrinkSpecifies how much a flex item should shrink when there's too little space in a flex container
fontA shorthand for the seven properties used for fonts
font-familyDefines what font an element will use when it has text in it
font-sizeSets the default size of text characters
font-size-adjustControls the sizing of lowercase letters
font-stretchDefines how wide or narrow the characters should be
font-styleDefines the text font style
font-weightDefines how thick or thin the characters should be

H

hanging-punctuationDefines if punctuation marks should be displayed outside of the lines to keep them properly aligned

J

justify-contentAligns flex items along the horizontal axis of the container

L

line-heightDefines the line height

M

marginAdds space around an element

N

nav-downDefines where the web page will navigate when the downwards arrow navigation key is pressed
nav-indexSets the sequence of navigation, or tabbing, order for elements
nav-leftDefines where the web page will navigate when the left arrow navigation key is pressed
nav-rightDefines where the web page will navigate when the right arrow navigation key is pressed
nav-upDefines where the web page will navigate when the upwards arrow navigation key is pressed

O

opacitySets the opacity level for an element
orderDefines the position of a specific flex item in the order of items in the same container
outlineDraws a line outside the element
outline-offsetAdds space between the outline and the border of the element
overflowDefines how the element behaves when the content cannot fit within its borders
overflow-xDefines how left and right sides of a container react to overflowing content
overflow-yDefines how top and bottom sides of a container react to overflowing content

P

paddingAdds space around an element
perspectiveDefines how far away an object is to create a 3D perspective
perspective-originSpecifies where a 3D element originates from on the x– and y– axis
positionSpecifies how an element is positioned

R

resizeSpecifies whether a user can resize the element

T

tab-sizeDefines how much space the tab character is going to take up in the text
text-alignDefines the horizontal text alignment inside of an element
text-align-lastDefines the horizontal alignment for the last line of text
text-decorationA shorthand for the three properties used for text decoration lines
text-decoration-colorSets the color for all text decoration lines
text-decoration-lineSpecifies where text decoration line is displayed (below, above or through the text)
text-decoration-styleDefines the style of text decoration line
text-emphasisA shorthand for text-emphasis-style and text-emphasis-color
text-overflowDefines how the presence of overflowed content that is not displayed will be shown to the user
text-shadowAdds a shadow to the text
text-transformControls the capitalization of the text
transformApplies various transformations to an element
transitionA shorthand for the four properties used for transition
transition-delaySpecifies the transition starting point in time
transition-durationSpecifies how long a transition takes to finish
transition-propertyDefines the CSS property that is affected by the transition effect
transition-timing-functionSpecifies the speed curve of a transition

V

vertical-alignSpecifies the vertical alignment for items inside an element

W

word-breakDefines the line breaking rules for words when they reach the end of the line
word-wrapAllows breaking long words and wrapping them in the next line

Z

Css Code Cheat Sheet

z-indexDefines a position of an element on the z-axis

Css Animation Cheat Sheet

:@

Css Animation Cheat Sheet

:hoverDefines how elements should be styled when they are hovered on
@font-faceAllows you to use a font file and define the name of the font instead of having to use a web-safe font
@keyframesAllows specifying code for the animation
@mediaSpecifies different style rules for different devices and/or media types