How we choose which HTML to style.
/* 1. Element Selector */
p { color: blue; }
/* 2. Class Selector (Use .) */
.btn-red { background: red; }
/* 3. ID Selector (Use # - Unique) */
#main-title { font-size: 30px; }
/* 4. Group Selector (Use ,) */
h1, h2, h3 { color: green; }
.demo-class (Reusable)
Element Selector (Global)
Every element is a box. Understanding these layers is mandatory for layout control.
div {
margin: 20px;
border: 2px solid green;
padding: 15px;
}
Block (new line) vs Inline (same line).
display: block; /* or inline-block */
Relative, Absolute, Fixed (scrolling), and Static.
position: fixed; top: 0;
This box uses Relative positioning, allowing the red tag to sit Absolute in the corner.
The easiest way to align items horizontally or vertically.
.container {
display: flex;
justify-content: center;
align-items: center;
flex-direction: row;
}
Use space-between to push items to the edges!
JUSTIFY-CONTENT: SPACE-BETWEEN