CSS Full Course Day 5 [Hindi] 💻 | Colors & Backgrounds 🚀 | Mohit Decodes
🎨 CSS Tutorial – Day 5: Colors & Backgrounds
Welcome to Day 5 of the CSS Full Course [Hindi] by Mohit Decodes! Today, we’ll learn how to style your web pages with beautiful colors and backgrounds using CSS.
🔹 CSS Colors
You can apply colors using:
- Color names
css
CopyEdit
color: red;
- Hexadecimal codes
css
CopyEdit
color: #ff5733;
- RGB values
css
CopyEdit
color: rgb(255, 87, 51);
- RGBA (with transparency)
css
CopyEdit
color: rgba(255, 87, 51, 0.7);
- HSL and HSLA
css
CopyEdit
color: hsl(9, 100%, 60%);
🔹 Background Properties
background-color
— Set solid background colorbackground-image
— Add image backgroundsbackground-repeat
— Control repeating of background images (no-repeat
,repeat-x
,repeat-y
)background-position
— Position the background image (center
,top right
, etc.)background-size
— Resize background image (cover
,contain
, or specific dimensions)background-attachment
— Fix the background (fixed
,scroll
)background
— Shorthand property to set multiple background properties at once
⚙️ Example CSS:
css
CopyEdit
body {
background-color: #f0f8ff;
color: #333;
}
.header {
background-image: url('header-bg.jpg');
background-repeat: no-repeat;
background-position: center;
background-size: cover;
height: 300px;
color: white;
text-align: center;
padding: 50px 0;
}
💡 Tips:
- Use RGBA or HSLA for transparent colors and overlays
- Optimize background images for faster loading
- Use contrasting colors for readability
- Experiment with gradients using
background-image: linear-gradient(...)