Comprehensive CSS Notes
1. Introduction to CSS
CSS (Cascading Style Sheets) is used to style and layout web pages.
It controls colors, fonts, spacing, and positioning.
It separates content (HTML) from design.
2. Types of CSS
1. Inline CSS – inside HTML tags.
Example: <p style='color:red;'>Text</p>
2. Internal CSS – inside <style> tag in <head>.
3. External CSS – separate .css file.
Example: <link rel='stylesheet' href='[Link]'>
3. CSS Syntax
A CSS rule has a selector and declaration block.
Example:
p{
color: blue;
font-size: 16px;
4. Selectors
Element Selector: p {}
Class Selector: .className {}
ID Selector: #idName {}
Universal Selector: * {}
Grouping: h1, h2, p {}
5. Colors and Background
color: red;
background-color: lightblue;
background-image: url('[Link]');
6. Box Model
Content → Padding → Border → Margin
Controls spacing and layout.
7. Text and Fonts
font-size: 16px;
font-family: Arial;
text-align: center;
font-weight: bold;
8. Layout Techniques
display: block, inline, flex
position: relative, absolute
float and clear
Flexbox and Grid systems
9. Responsive Design
Media Queries example:
@media (max-width: 600px) {
body {background-color: lightgray;}
}
10. Advantages of CSS
Separates content and design
Improves speed
Reusable styles
Better user experience
11. Example Full CSS
body {
font-family: Arial;
margin: 0;
h1 {
color: blue;
.container {
display: flex;