CSS Tutorial - CSS Syntax & Selectors
๐ CSS Syntax
๐ CSS Rule Structure:
selector { property: value; }
Jaise: h1 { color: red; }
๐ฏ Parts of CSS Rule
Anatomy
h1 {
color: blue;
font-size: 24px;
}
/* selector = h1 */
/* property = color, font-size */
/* value = blue, 24px */
๐ Types of Selectors
| Type | Syntax | Example |
|---|---|---|
| Element | tagname | p { } |
| Class | .classname | .box { } |
| ID | #idname | #header { } |
| Universal | * | * { } |
โ ๏ธ Class vs ID:
Class (.) = Multiple elements
ID (#) = Sirf ek element (unique)
Example
p { color: green; }
.text { font-size: 20px; }
#title { color: red; }