Logo

Codcups

Complete CSS Reference's

Intro Of CSS?

CSS stands for Cascading Style Sheets. It is a language used to describe the style of an HTML document. CSS controls how HTML elements appear on screen, including layout, colors, fonts, spacing, and responsiveness. It separates content from design, making websites easier to maintain and customize. CSS can be written inline (within HTML tags), internally (in a <style> block), or externally (via a . css file).

🔷 1. CSS Selectors

SelectorDescription
*Universal selector (selects all elements)
elementType selector (e.g., div, p)
.classClass selector
#idID selector
element, elementGroup selector
element elementDescendant selector
element > elementChild selector
element + elementAdjacent sibling selector
element ~ elementGeneral sibling selector
[attribute]Attribute selector
:hoverPseudo-class for hover
:nth-child(n)Selects the nth child
::before / ::afterPseudo-elements for adding content

🔷 2. CSS Keywords

KeywordUse
inheritInherit value from parent element
initialDefault value as defined by the browser
unsetResets property to inherited or default
autoLet the browser calculate the value
noneOften used to disable a property (e.g., display, border)
blockDisplay type
inlineDisplay type
flexDisplay type
gridDisplay type
relativePosition type
absolutePosition type
fixedPosition type
stickyPosition type
transparentColor keyword

🔷 3. Common CSS Properties

PropertyDescription
colorText color
background-colorElement background color
background-imageSets an image as background
width / heightSize of element
paddingSpace inside element border
marginSpace outside element border
borderBorder of the element
font-sizeSize of text
font-familyFont type
font-weightBoldness of text
text-alignHorizontal alignment of text
vertical-alignVertical alignment
line-heightLine spacing
displayDisplay behavior (block, inline, flex, etc.)
positionPositioning method
top, right, bottom, leftPosition offsets
z-indexStack order of elements
overflowControls content overflow (hidden, scroll)
visibilityVisibility of element (visible, hidden)
opacityTransparency (0 to 1)
box-shadowAdds shadow to element
text-shadowAdds shadow to text
transitionAdds animation between property changes
transformRotate, scale, skew, move
animationDefines keyframe animation

🔷 4. CSS Value Units

UnitDescription
pxPixels (absolute unit)
%Percentage (relative unit)
emRelative to parent font size
remRelative to root font size
vh / vwViewport height/width
frFractional unit (used in grid)

🔷 5. Media Queries (Responsive CSS)

SyntaxDescription
@media screen and (max-width: 600px)Applies CSS on small screens
@media printApplies when printing
@media only screen and (min-width: 768px)Tablet or desktop view

Click to go back on notes page.