CSS
Basic Syntax
selector {
property: value;
}
Selector: The HTML element to style (e.g., h1, .class-name,
#id-name).
Property: The CSS property to change (e.g., color, font-
size).
Value: The value for the property (e.g., blue, 16px).
Types of CSS:
There are three main types of CSS:
1. Inline CSS
2. Internal CSS
3. External CSS
Inline CSS
- Applied directly to an HTML element
- Uses the `style` attribute
- Example: `<p style="color: red;">Text</p>`
Internal CSS
- Defined within the `<style>` tag
- Placed in the HTML document's `<head>` section
- Example:
```
<head>
<style>
p{
color: red;
}
</style>
</head>
External CSS
- Linked to an external CSS file
- Uses the `<link>` tag
- Example:
<head>
<link rel="stylesheet" type="text/css"
href="styles.css">
</head>
CSS Selectors
Element Selector: h1 { color: red; }
Class Selector: .class-name { color: green; }
ID Selector: #id-name { color: blue; }
Descendant selector : parent child { color:black;}
Universal Selector : * {margin: 0;}
h1 { .container p{
color: blue; color: red;
font-size: 36px; }
text-align: center;
}
CSS Box Model
• Content: The actual content inside the element.
• Padding: Space between the content and the border.
• Border: The boundary around the content and
padding.
• Margin: Space outside the border.
Positioning Elements
• Static Positioning
• Relative Positioning
• Absolute Positioning
• Fixed Positioning
• Sticky Positioning
Flexbox
• flex-direction: Defines the direction of flex items (row,
column, etc.).
• flex-wrap: Specifies whether flex items should wrap
onto multiple lines.
• justify-content: Aligns items along the main axis
(horizontal by default).
• align-items: Aligns items along the cross axis (vertical
by default).