CSS Cheat Sheet
CSS Cheat Sheet
Thanks for trying out Immersive Reader. Share your feedback with us.
CSS Introduction :
CSS stands for Cascading Style Sheets. It is used to style HTML pages. CSS determines how
HTML elements will be displayed on the screen. CSS files end with .css extension. Using CSS, you
can control the look and feel of the whole website with just one CSS file. In this post, I have tried
to write a cheat sheet for all important CSS properties along with their possible values. You can
download this cheat sheet and refer whenever required.
CSS Syntax :
CSS syntax consists of a selector and a declaration block where Selector is an HTML element
which you want to style. Declaration block must be enclosed within { }. Declaration block contains
many declaration statements separated by semicolon(;). Each declaration statement contains a CSS
property and a value separated by a colon(:).
CSS Selectors :
CSS selectors are the HTML elements which you want to style. There are different ways to select
an HTML element in CSS. Below table describes the same.
elements
Pseudo Class :active, :focus, :hover, :link, :visited, :target, :checked, It selects the
Selectors :disabled, :enabled, :empty, :first-child, :last-child, elements based on
:only-child, :first-of-type, :last-of-type, :invalid, their state.
:not(selector), :nth-child(n), :nth-last-child(n), :nth-of-
type(n), :nth-last-of-type(n), :in-range, :out-of-range,
:required, :optional, :read-only, :read-write
CSS Insertion :
There are three ways you can link CSS with an HTML document.
read://https_javaconceptoftheday.com/?url=https%3A%2F%2Fjavaconceptoftheday.com%2Fcss-cheat-sheet%2F 2/19
8/31/23, 1:39 PM CSS Cheat Sheet
h1 {color: red;}
</style>
CSS Comments :
CSS Backgrounds :
CSS background properties are used to add background effects to an HTML element.
background- left top | left center | left bottom | right It specifies starting position of a
position top | right center | right bottom | center background image.
top | center center | center bottom | x%
y% | xpos ypos | initial | inherit
background- scroll | fixed | local | initial | inherit This property specifies whether
attachment the background image is fixed or
scrolls with the rest of the page.
background- auto | length | cover | contain | initial | It specifies the size of the
size inherit background image.
read://https_javaconceptoftheday.com/?url=https%3A%2F%2Fjavaconceptoftheday.com%2Fcss-cheat-sheet%2F 3/19
8/31/23, 1:39 PM CSS Cheat Sheet
CSS Borders :
CSS border properties are used to define style for an element’s border.
border-style dotted | dashed | solid | double | It defines the style for all four borders
groove | ridge | inset | outset | hidden of an element.
| none | inherit | initial
border-top- dotted | dashed | solid | double | It defines the style for top border of
style groove | ridge | inset | outset | hidden an element.
| none | inherit | initial
border- dotted | dashed | solid | double | It defines the style for bottom border
bottom-style groove | ridge | inset | outset | hidden of an element.
| none | inherit | initial
border-left- dotted | dashed | solid | double | It defines the style for left border of
style groove | ridge | inset | outset | hidden an element.
| none | inherit | initial
border-right- dotted | dashed | solid | double | It defines the style for right border of
style groove | ridge | inset | outset | hidden an element.
| none | inherit | initial
border-width medium | thick | thin | length | initial It specifies the width of all four
| inherit borders of an element.
border-top- medium | thick | thin | length | initial It specifies the width of top border of
width | inherit an element.
read://https_javaconceptoftheday.com/?url=https%3A%2F%2Fjavaconceptoftheday.com%2Fcss-cheat-sheet%2F 4/19
8/31/23, 1:39 PM CSS Cheat Sheet
border- medium | thick | thin | length | initial It specifies the width of bottom
bottom-width | inherit border of an element.
border-left- medium | thick | thin | length | initial It specifies the width of left border of
width | inherit an element.
border-right- medium | thick | thin | length | initial It specifies the width of right border
width | inherit of an element.
border-color color | transparent | initial | inherit It sets the color for all four borders of
an element.
border-top- color | transparent | initial | inherit It sets the color for top border of an
color element.
border- color | transparent | initial | inherit It sets the color for bottom border of
bottom-color an element.
border-left- color | transparent | initial | inherit It sets the color for left border of an
color element.
border-right- color | transparent | initial | inherit It sets the color for right border of an
color element.
read://https_javaconceptoftheday.com/?url=https%3A%2F%2Fjavaconceptoftheday.com%2Fcss-cheat-sheet%2F 5/19
8/31/23, 1:39 PM CSS Cheat Sheet
width image.
border-image- stretch | repeat | round | space | initial It specifies whether the border image
repeat | inherit of an element should be repeated or
stretched or rounded.
border-image- number | % | fill | initial | inherit It specifies how to slice the border
slice image.
border-image- length | number | initial | inherit This property sets outset of a border
outset image.
CSS Margins :
CSS margin properties are used to apply space around HTML elements. Margin is the space around
an element outside its border.
margin length | auto | initial It used to set margin of an element around all sides –
| inherit top, bottom, left and right.
read://https_javaconceptoftheday.com/?url=https%3A%2F%2Fjavaconceptoftheday.com%2Fcss-cheat-sheet%2F 6/19
8/31/23, 1:39 PM CSS Cheat Sheet
CSS Padding :
CSS padding properties apply space between content of an HTML element and it’s border. Padding
is the space around the content of an element inside its border.
CSS Dimensions :
CSS dimension properties are used to set the height and width of an element.
read://https_javaconceptoftheday.com/?url=https%3A%2F%2Fjavaconceptoftheday.com%2Fcss-cheat-sheet%2F 7/19
8/31/23, 1:39 PM CSS Cheat Sheet
CSS Shadow :
box- none | h-offset v-offset blur spread color | inset | It adds shadow effect to an
shadow initial | inherit element.
text- h-shadow v-shadow blur-radius color | none | It adds shadow effect to the
shadow initial | inherit text.
CSS Overflow :
overflow visible | hidden | clip | This property specifies what should happen when
scroll | auto | initial | an element’s content is too big to fit in the specified
inherit area.
overflow-x visible | hidden | scroll | It specifies what to do with the left/right edges of
auto | initial | inherit the content if it overflows the element’s specified
area
overflow-y visible | hidden | scroll | It specifies what to do with the top/bottom edges of
auto | initial | inherit the content if it overflows the element’s content
area.
overflow- normal | anywhere | It specifies whether or not the browser can break
wrap break-word | initial | lines with long words, if they overflow element’s
inherit container
CSS Outline :
CSS outline properties define outline drawn outside the border of an element.
outline- dotted | dashed | solid | double | groove | It defines style for outline of an
style ridge | inset | outset | hidden | none | initial element.
read://https_javaconceptoftheday.com/?url=https%3A%2F%2Fjavaconceptoftheday.com%2Fcss-cheat-sheet%2F 8/19
8/31/23, 1:39 PM CSS Cheat Sheet
| inherit
CSS Text :
font-size- number | none | initial | inherit It specifies the font-size adjustment when
adjust the selected font-size is not available.
font-style normal | italic | oblique | initial | It specifies font style for a text.
inherit
read://https_javaconceptoftheday.com/?url=https%3A%2F%2Fjavaconceptoftheday.com%2Fcss-cheat-sheet%2F 9/19
8/31/23, 1:39 PM CSS Cheat Sheet
text-align left | right | center | justify | initial This property horizontally aligns the text.
| inherit
vertical-align baseline | length | sub | super | top It specifies vertical alignment of not only
| text-top | middle | bottom | text- text but any element.
bottom | initial | inherit
text-align- auto | left | right | center | justify | It specifies horizontal alignment for last
last start | end | initial | inherit line.
text- none | underline | overline | line- It specifies the text decoration like
decoration- through | initial | inherit underline, overline or line-thorugh.
line
text- solid | double | dotted | dashed | It specifies the style for text decoration
decoration- wavy | initial | inherit line.
style
text- color | initial | inherit It specifies the color for text decoration
decoration- line.
color
read://https_javaconceptoftheday.com/?url=https%3A%2F%2Fjavaconceptoftheday.com%2Fcss-cheat-sheet%2F 10/19
8/31/23, 1:39 PM CSS Cheat Sheet
text block.
letter- normal | length | initial | inherit It adds the space between characters of a
spacing text.
word- normal | length | initial | inherit It adds the space between words of a text
spacing block.
white-space normal | nowrap | pre | pre-line | It specifies how to handle the white spaces
pre-wrap | initial | inherit in a text.
text-shadow h-shadow v-shadow blur-radius It adds the shadow effect to the text.
color | none | initial | inherit
word-break normal | break-all | keep-all | It specifies how words should break at the
break-word | initial | inherit end of a line.
writing- horizontal-tb | vertical-rl | It specifies how lines of text are laid out.
mode vertical-lr
CSS Lists :
CSS list properties are used to style ordered and unordered lists.
list-style- disc | circle | square | decimal | decimal-leading-zero | It specifies the list item
type georgian | hebrew | hiragana | hiragana-iroha | katakana marker in a list.
| katakana-iroha | lower-alpha | lower-greek | lower-
latin | lower-roman | upper-alpha | upper-greek | upper-
latin | upper-roman | armenian | none | initial | inherit
read://https_javaconceptoftheday.com/?url=https%3A%2F%2Fjavaconceptoftheday.com%2Fcss-cheat-sheet%2F 11/19
8/31/23, 1:39 PM CSS Cheat Sheet
CSS Table :
table-layout auto | fixed | initial | It specifies layout for table cells, rows and columns.
inherit
caption-side top | bottom | initial | It specifies the placement for table caption.
inherit
empty-cells show | hide | initial | It specifies whether hide or show the borders of the
inherit empty cells of a table.
border- length | initial | inherit It adds the space between the borders of adjacent cells
spacing of a table.
border- separate | collapse | It sets whether the table cell borders should be
collapse initial | inherit collapsed into single border or be separated.
CSS Visibility :
CSS Positions :
read://https_javaconceptoftheday.com/?url=https%3A%2F%2Fjavaconceptoftheday.com%2Fcss-cheat-sheet%2F 12/19
8/31/23, 1:39 PM CSS Cheat Sheet
top auto | length | % | initial | inherit It sets top margin for the positioned
element.
bottom auto | length | % | initial | inherit It sets bottom margin for the positioned
element.
left auto | length | % | initial | inherit It sets left margin for the positioned
element.
right auto | length | % | initial | inherit It sets right margin for the positioned
element.
float none | left | right | initial | inherit This property specifies how to float an
element.
clear none | left | right | both | initial | It controls the flow next to floated
inherit elements.
CSS Columns :
column-gap length | normal | initial | inherit It specifies the gap between the
columns.
column-fill balance | auto | initial | inherit It specifies how to file the columns.
read://https_javaconceptoftheday.com/?url=https%3A%2F%2Fjavaconceptoftheday.com%2Fcss-cheat-sheet%2F 13/19
8/31/23, 1:39 PM CSS Cheat Sheet
column-rule- none | hidden | dotted | dashed | solid | It specifies the style of a rule
style double | groove | ridge | inset | outset | between the columns.
initial | inherit
column-rule- color | initial | inherit It specifies the color for the column
color rule.
column-rule- medium | thin | thick | length | initial | It specifies the width for the
width inherit column rule.
flex-wrap nowrap | wrap | wrap-reverse | initial | inherit It specifies whether the flexible
items should wrap or not.
read://https_javaconceptoftheday.com/?url=https%3A%2F%2Fjavaconceptoftheday.com%2Fcss-cheat-sheet%2F 14/19
8/31/23, 1:39 PM CSS Cheat Sheet
align- stretch | center | flex-start | flex-end | space- It is used to align flexible lines
content between | space-around | space-evenly | inside a flexible container.
initial | inherit
align-self auto | stretch | center | flex-start | flex-end | It is used to align selected item
baseline | initial | inherit inside a flexible container.
CSS Transitions :
transition- none | all | property | initial | inherit It specifies the CSS property
property for which transition effect
will takes place.
transition- linear | ease | ease-in | ease-out | ease-in-out | It specifies the speed curve
timing- step-start | step-end | steps(int,start | end) | of the transition effect.
function cubic-bezier(n,n,n,n) | initial | inherit
CSS 2D / 3D :
read://https_javaconceptoftheday.com/?url=https%3A%2F%2Fjavaconceptoftheday.com%2Fcss-cheat-sheet%2F 15/19
8/31/23, 1:39 PM CSS Cheat Sheet
transform- flat | preserve-3d | initial It specifies how nested elements are rendered in
style | inherit 3D space.
CSS Animation :
animation-fill- none | forwards | backwards | both | initial | It specifies the style when an
mode inherit animation is not playing.
read://https_javaconceptoftheday.com/?url=https%3A%2F%2Fjavaconceptoftheday.com%2Fcss-cheat-sheet%2F 16/19
8/31/23, 1:39 PM CSS Cheat Sheet
CSS Grid :
row-gap length | normal | initial | inherit It specifies the gap between the
rows of a grid.
column- length | normal | initial | inherit It specifies the gap between the
gap columns of a grid.
read://https_javaconceptoftheday.com/?url=https%3A%2F%2Fjavaconceptoftheday.com%2Fcss-cheat-sheet%2F 17/19
8/31/23, 1:39 PM CSS Cheat Sheet
grid-auto- auto | max-content | min-content | length It sets the default row size of a
rows grid layout.
grid-auto- row | column | dense | row dense | column It specifies how auto placed items
flow dense will be inserted in the grid.
CSS Miscellaneous :
box-sizing content-box | border-box | initial | inherit It defines how the width and height
of an element are calculated – should
they include padding and borders, or
not.
break-after auto | all | always | avoid | avoid-column It handles the page break, column
| avoid-page | avoid-region | column | break, or region break after the
read://https_javaconceptoftheday.com/?url=https%3A%2F%2Fjavaconceptoftheday.com%2Fcss-cheat-sheet%2F 18/19
8/31/23, 1:39 PM CSS Cheat Sheet
break- auto | all | always | avoid | avoid-column It handles the page break, column
before | avoid-page | avoid-region | column | break, or region break before the
left | page | recto | region | right | verso | specified element.
initial | inherit
break- auto | all | always | avoid | avoid-column It handles the page break, column
inside | avoid-page | avoid-region | column | break, or region break inside the
left | page | recto | region | right | verso | specified element.
initial | inherit
object-fit fill | contain | cover | scale-down | none | It specifies how an element (<img>
initial | inherit or <video>) should be resized to fit
into its container.
object- left | center | right | length | % | initial | It is used along with object-fit to
position inherit position an element (<img> or
<video>).
user-select auto | none | text | all It sets whether the text of an element
can be selected or not.
white- normal | nowrap | pre | pre-line | pre- It specifies how white-space inside an
space wrap | initial | inherit element is handled.
Also Read :
read://https_javaconceptoftheday.com/?url=https%3A%2F%2Fjavaconceptoftheday.com%2Fcss-cheat-sheet%2F 19/19