CSS (Cascading Style Sheets) is used to style HTML elements โ adding colors, spacing, layout, and more.
1๏ธโฃ CSS Syntax
selector {
property: value;
}Example:
h1 {
color: blue;
font-size: 32px;
}2๏ธโฃ How to Add CSS
โฆ Inline:
<p style="color: red;">Hello</p>
โฆ Internal (within HTML):
<style>
p { color: green; }
</style>
โฆ External (best practice):
<link rel="stylesheet" href="style.css">
3๏ธโฃ Selectors
โฆ
* โ All elementsโฆ
p โ All <p> tagsโฆ
.class โ Elements with classโฆ
#id โ Element with specific ID#title { color: blue; }.red-text { color: red; }4๏ธโฃ Colors & Fonts
body {
background-color: #f2f2f2;
color: #333;
font-family: Arial, sans-serif;
}5๏ธโฃ Box Model
Every HTML element is a box:
content + padding + border + margin
6๏ธโฃ Layout with Flexbox
{
display: flex;
justify-content: space-between;
align-items: center;
}7๏ธโฃ Responsive Design
@media (max-width: 600px) {
body {
font-size: 14px;
}
}8๏ธโฃ Hover Effects
button:hover {
background-color: black;
color: white;
}9๏ธโฃ Common Properties
โฆ
color โ Text colorโฆ
background-color โ Backgroundโฆ
margin & padding โ Spacingโฆ
border โ Border styleโฆ
width / height โ Sizeโฆ
text-align โ Alignment๐ก Tip: Organize your styles using class names and external CSS files for better scalability.
๐ฌ Tap โค๏ธ for more!