CSS_Basic_Guide
CSS_Basic_Guide
1. What is CSS?
CSS (Cascading Style Sheets) is used to style HTML elements. It controls layout, colors, fonts, and
responsiveness of a webpage.
2. CSS Syntax
A CSS rule consists of a selector and a declaration block:
selector {
property: value;
}
Example:
p{
color: blue;
font-size: 16px;
}
3. Types of CSS
1. Inline CSS: <p style='color: red;'>Red text</p>
2. Internal CSS: <style> p { color: green; } </style>
3. External CSS: <link rel='stylesheet' href='styles.css'>
4. CSS Selectors
Common selectors include:
- * (Universal Selector)
- element (Type Selector)
- .class (Class Selector)
- #id (ID Selector)
- h1, p (Group Selector)
Box Model:
.box { width: 200px; height: 100px; margin: 20px; padding: 15px; border: 2px dashed blue; }
6. Responsive Design
@media (max-width: 600px) {
body { background-color: lightblue; }
}