ЁЯУЪ CSS Week 2 - Interactive Study Guide

Days 8-14: CSS Basics to Intermediate with Interview Questions

ЁЯУМ Day 8: Introduction to CSS

What is CSS?

CSS stands for Cascading Style Sheets. Think of it like this: HTML is the skeleton of a webpage (structure), and CSS is the clothes and makeup (styling). CSS tells the browser HOW to display HTML elements - colors, sizes, positions, fonts, etc.
ЁЯОп Key Points to Remember:
  • CSS makes websites look beautiful and organized
  • Without CSS, websites look plain and boring (like plain text)
  • CSS is separate from HTML (though it can be mixed)
  • One CSS file can style multiple HTML pages
1я╕ПтГг Inline CSS (рд╕реАрдзреЗ HTML element рдореЗрдВ)

CSS directly written in the HTML tag itself.

<p style="color: red; font-size: 20px;">Hello World</p>

Hinglish: Yeh tarika sirf ek element ko style karne ke liye use hota hai. Agar 100 paragraphs hain to 100 baar likhna padega!

2я╕ПтГг Internal CSS (HTML file ke andar)

CSS written inside <style> tag in the <head> section.

<head> <style> p { color: blue; } </style> </head>

Hinglish: Ek hi file mein HTML aur CSS dono hote hain. Chhote projects ke liye theek hai.

3я╕ПтГг External CSS (Alag file - рд╕рдмрд╕реЗ рдЕрдЪреНрдЫрд╛ рддрд░реАрдХрд╛)

CSS in a separate file (style.css) linked to HTML.

<!-- In HTML file --> <link rel="stylesheet" href="style.css"> <!-- In style.css file --> p { color: green; }

Hinglish: Yeh sabse professional tarika hai! Ek CSS file se multiple HTML pages ko style kar sakte ho. Maintenance bhi easy hai.

1. Universal Selector (*)

Selects ALL elements on the page.

* { margin: 0; padding: 0; }

Real-world example: Jab aap sabhi elements se default spacing hatana chahte ho.

2. Element Selector

Selects all elements of a specific type.

p { color: red; } h1 { font-size: 30px; }

Real-world example: Sabhi paragraphs ko red color dena.

3. Class Selector (.classname)

Selects elements with a specific class. One element can have multiple classes.

.button { background: blue; padding: 10px; } <button class="button">Click Me</button>

Real-world example: Multiple buttons, cards, or containers ko same style dena.

4. ID Selector (#idname)

Selects a unique element with a specific ID. Each ID should be used only ONCE.

#header { background: navy; color: white; } <div id="header">Welcome</div>

Real-world example: Navbar, footer, main content area - unique sections ke liye.

5. Grouping Selector (,)

Apply same style to multiple selectors.

h1, h2, h3 { color: purple; font-weight: bold; }

Real-world example: Sabhi headings ko same color dena bina ek-ek karke likhe.

ЁЯТ╝ Interview Questions - Day 8

Q1: CSS kya hota hai aur HTML se alag kyu hota hai?
Answer:
HTML structure provide karta hai (skeleton), CSS styling provide karta hai (clothes).

HTML bina CSS ke plain text jaisa dikhta hai. CSS se colors, fonts, spacing, animations sab add hote hain. Alag file rakhne se code organized rehta hai aur reuse karna easy hota hai.

Example:
HTML: <p>Hello</p> тЖТ Plain text
CSS: p { color: red; font-size: 20px; } тЖТ Styled text
Q2: Inline, Internal, aur External CSS mein kya difference hai?
Answer:
Inline: Style attribute directly HTML tag mein. Sirf ek element ke liye. Reuse nahi kar sakte.
Internal: <style> tag HTML file ke head mein. Ek file mein CSS aur HTML. Chhote projects ke liye theek.
External: Alag CSS file. Multiple HTML pages ko style kar sakte ho. Professional aur maintainable.

Production websites mein hamesha external CSS use hota hai kyunki scalable aur organized hota hai.
Q3: Class selector aur ID selector mein kya difference hai?
Answer:
Class (.classname): Multiple elements ke liye. Ek element mein multiple classes ho sakte hain.
ID (#idname): Unique element ke liye. Ek page mein ek ID sirf ek baar use hona chahiye.

Example:
<!-- Class: Multiple buttons --> <button class="btn">Button 1</button> <button class="btn">Button 2</button> <!-- ID: Unique header --> <div id="main-header">...</div>
Class = reusable, ID = unique. Agar 10 buttons hain to class use karo, agar sirf ek navbar hai to ID use karo.
Q4: CSS Selectors ka hierarchy (priority) kya hota hai?
Answer:
Priority order (highest to lowest):
1. Inline CSS (style attribute) - рд╕рдмрд╕реЗ рдЬреНрдпрд╛рджрд╛ priority
2. ID selector (#)
3. Class selector (.)
4. Element selector (p, div, etc.)
5. Universal selector (*) - рд╕рдмрд╕реЗ рдХрдо priority

Agar ek element ko multiple selectors se style kiya gaya to highest priority wala apply hoga. Isko "Specificity" kehte hain.

ЁЯУж Day 9: CSS Box Model (Most Important!)

What is Box Model?

рд╣рд░ HTML element рдПрдХ box рд╣реИред Box Model рдмрддрд╛рддрд╛ рд╣реИ рдХрд┐ рдпрд╣ box рдХреИрд╕реЗ рдмрдирд╛ рд╣реИред рд╕реЛрдЪреЛ - рдПрдХ gift box рд╣реИ рдЬрд┐рд╕рдореЗрдВ:
  • Content: Gift (actual content)
  • Padding: Bubble wrap (space inside)
  • Border: Box ka edge (boundary)
  • Margin: Space outside (distance from other boxes)

ЁЯУК Box Model Visualization

MARGIN (рдмрд╛рд╣рд░ рдХреА рдЬрдЧрд╣)
BORDER (рдХрд┐рдирд╛рд░рд╛)
PADDING (рдЕрдВрджрд░ рдХреА рдЬрдЧрд╣)
CONTENT
1. PADDING (рдЕрдВрджрд░ рдХреА рдЬрдЧрд╣)

Content рдФрд░ border рдХреЗ рдмреАрдЪ рдХреА рдЬрдЧрд╣ред Element рдХреЗ рдЕрдВрджрд░ рдХреА spaceред

div { padding: 20px; } /* рд╕рднреА sides рдкрд░ 20px */ div { padding: 10px 20px; } /* Top/Bottom: 10px, Left/Right: 20px */ div { padding: 10px 20px 30px 40px; } /* Top, Right, Bottom, Left (clockwise) */

Real-world example: Button рдХреЗ рдЕрдВрджрд░ text рдХреЛ border рд╕реЗ рджреВрд░ рд░рдЦрдирд╛ред

рдпрд╣ padding рд╣реИ - text рдХреЗ рдЪрд╛рд░реЛрдВ рдУрд░ space
2. BORDER (рдХрд┐рдирд╛рд░рд╛)

Element рдХреЗ рдЪрд╛рд░реЛрдВ рдУрд░ рдХреА line/edgeред

div { border: 5px solid red; } /* width, style, color */ div { border-width: 5px; } div { border-style: solid; /* solid, dashed, dotted */ } div { border-color: red; } div { border-radius: 10px; /* rounded corners */ }

Real-world example: Cards, input boxes, buttons рдХреЛ define рдХрд░рдирд╛ред

рдпрд╣ border рд╣реИ - element рдХреЗ рдЪрд╛рд░реЛрдВ рдУрд░
3. MARGIN (рдмрд╛рд╣рд░ рдХреА рдЬрдЧрд╣)

Element рдХреЗ рдмрд╛рд╣рд░ рдХреА рдЬрдЧрд╣ред рджреВрд╕рд░реЗ elements рд╕реЗ distanceред

div { margin: 30px; } /* рд╕рднреА sides рдкрд░ 30px */ div { margin: 20px auto; } /* Top/Bottom: 20px, Left/Right: auto (center рдХрд░рддрд╛ рд╣реИ) */ div { margin-top: 10px; } div { margin-bottom: 20px; }

Real-world example: Cards рдХреЛ рдПрдХ-рджреВрд╕рд░реЗ рд╕реЗ рджреВрд░ рд░рдЦрдирд╛ред

рдпрд╣ margin рд╣реИ - element рдХреЗ рдмрд╛рд╣рд░ space
box-sizing: content-box (Default)

Width рдФрд░ height рд╕рд┐рд░реНрдл content рдХреЗ рд▓рд┐рдПред Padding рдФрд░ border add рд╣реЛрддреЗ рд╣реИрдВред

div { width: 200px; padding: 20px; border: 5px solid; box-sizing: content-box; } /* Total width = 200 + 20 + 20 + 5 + 5 = 250px */

тЪая╕П Problem: Width calculate рдХрд░рдирд╛ рдореБрд╢реНрдХрд┐рд▓ рд╣реЛ рдЬрд╛рддрд╛ рд╣реИред

box-sizing: border-box (рдмреЗрд╣рддрд░ рддрд░реАрдХрд╛)

Width рдФрд░ height рдореЗрдВ padding рдФрд░ border рд╢рд╛рдорд┐рд▓ рд╣реЛрддреЗ рд╣реИрдВред

* { box-sizing: border-box; } /* рд╕рднреА elements рдХреЗ рд▓рд┐рдП */ div { width: 200px; padding: 20px; border: 5px solid; } /* Total width = 200px (padding рдФрд░ border included) */

тЬЕ Benefit: Width exactly рд╡рд╣реА рд╣реЛрддрд╛ рд╣реИ рдЬреЛ рдЖрдк specify рдХрд░рддреЗ рд╣реЛред

ЁЯТб Best Practice: рд╣рдореЗрд╢рд╛ рдЕрдкрдиреА CSS рдХреА рд╢реБрд░реБрдЖрдд рдореЗрдВ рдпрд╣ рд▓рд┐рдЦреЛ:
* { box-sizing: border-box; }
1. Display: Block

рдкреВрд░реА width рд▓реЗрддрд╛ рд╣реИред рд╣рдореЗрд╢рд╛ рдирдИ line рд╕реЗ рд╢реБрд░реВ рд╣реЛрддрд╛ рд╣реИред

div { display: block; } /* Default: div, p, h1, section, etc. */

Visual Example:

Block 1 - рдкреВрд░реА width рд▓реЗрддрд╛ рд╣реИ
Block 2 - рдирдИ line рдкрд░
2. Display: Inline

рд╕рд┐рд░реНрдл рдЬрд┐рддрдиреА width рдЪрд╛рд╣рд┐рдПред рдПрдХ рд╣реА line рдкрд░ рд░рд╣рддреЗ рд╣реИрдВред

span { display: inline; } /* Default: span, a, strong, em, etc. */

Visual Example:

Inline 1 Inline 2 Inline 3

тЪая╕П Problem: Width/height set nahi kar sakteред Padding/margin top-bottom рдХрд╛рдо рдирд╣реАрдВ рдХрд░рддреЗред

3. Display: Inline-Block (Best of Both)

рдПрдХ рд╣реА line рдкрд░ рд░рд╣рддреЗ рд╣реИрдВ рд▓реЗрдХрд┐рди width/height/padding/margin рд╕рдм рдХрд╛рдо рдХрд░рддреЗ рд╣реИрдВред

button { display: inline-block; } /* Buttons, badges, small cards */

Visual Example:

Button 1
Button 2
Button 3
overflow: visible (Default)

Content box рд╕реЗ рдмрд╛рд╣рд░ рдирд┐рдХрд▓ рдЬрд╛рддрд╛ рд╣реИред

рдпрд╣ content рдмрд╣реБрдд рд▓рдВрдмрд╛ рд╣реИ рдФрд░ box рд╕реЗ рдмрд╛рд╣рд░ рдирд┐рдХрд▓ рдЬрд╛рдПрдЧрд╛ред рдпрд╣ default behavior рд╣реИред
overflow: hidden

Content рдХреЛ crop рдХрд░ рджреЗрддрд╛ рд╣реИред

рдпрд╣ content рдмрд╣реБрдд рд▓рдВрдмрд╛ рд╣реИ рд▓реЗрдХрд┐рди рдЫреБрдк рдЬрд╛рдПрдЧрд╛ред Extra content рджрд┐рдЦрд╛рдИ рдирд╣реАрдВ рджреЗрдЧрд╛ред
overflow: scroll

Scrollbar add рдХрд░рддрд╛ рд╣реИ (рд╣рдореЗрд╢рд╛)ред

рдпрд╣ content рдмрд╣реБрдд рд▓рдВрдмрд╛ рд╣реИ рдФрд░ scrollbar рджрд┐рдЦреЗрдЧрд╛ред рдЖрдк scroll рдХрд░рдХреЗ рдкреВрд░рд╛ content рджреЗрдЦ рд╕рдХрддреЗ рд╣реЛред Scrollbar рд╣рдореЗрд╢рд╛ рджрд┐рдЦрддрд╛ рд╣реИ рдЪрд╛рд╣реЗ content рдЫреЛрдЯрд╛ рд╣реЛ рдпрд╛ рдмрдбрд╝рд╛ред
overflow: auto (рд╕рдмрд╕реЗ рдЕрдЪреНрдЫрд╛)

рдЬрд░реВрд░рдд рдкрдбрд╝рдиреЗ рдкрд░ рд╣реА scrollbar рджрд┐рдЦрд╛рддрд╛ рд╣реИред

рдпрд╣ content рдмрд╣реБрдд рд▓рдВрдмрд╛ рд╣реИред Scrollbar рд╕рд┐рд░реНрдл рддрдм рджрд┐рдЦреЗрдЧрд╛ рдЬрдм content overflow рд╣реЛред рдпрд╣ рд╕рдмрд╕реЗ smart option рд╣реИред

ЁЯТ╝ Interview Questions - Day 9

Q1: Box Model kya hai? Iske components explain karo.
Answer:
Box Model рдмрддрд╛рддрд╛ рд╣реИ рдХрд┐ рд╣рд░ HTML element рдПрдХ rectangular box рд╣реИ рдЬрд┐рд╕рдореЗрдВ 4 parts рд╣реЛрддреЗ рд╣реИрдВ:

1. Content: Actual content (text, image)
2. Padding: Content рдФрд░ border рдХреЗ рдмреАрдЪ рдХреА space
3. Border: Element рдХреЗ рдЪрд╛рд░реЛрдВ рдУрд░ рдХреА boundary
4. Margin: Element рдХреЗ рдмрд╛рд╣рд░ рдХреА space (рджреВрд╕рд░реЗ elements рд╕реЗ distance)

Gift box ki tarah socho: Content = gift, Padding = bubble wrap, Border = box ka edge, Margin = boxes ke beech ki jagah.

Total Width = Content Width + Padding + Border + Margin
Q2: Padding aur Margin mein kya difference hai?
Answer:
Padding: Element рдХреЗ рдЕрдВрджрд░ рдХреА spaceред Content рдФрд░ border рдХреЗ рдмреАрдЪред
Margin: Element рдХреЗ рдмрд╛рд╣рд░ рдХреА spaceред рджреВрд╕рд░реЗ elements рд╕реЗ distanceред

Padding element ke andar hota hai (background color dikhta hai), Margin element ke bahar hota hai (background color nahi dikhta).

Example:
/* Padding - рдЕрдВрджрд░ рдХреА рдЬрдЧрд╣ */ button { padding: 20px; background: blue; } /* Background color padding area mein bhi dikhega */ /* Margin - рдмрд╛рд╣рд░ рдХреА рдЬрдЧрд╣ */ button { margin: 20px; } /* Background color margin area mein nahi dikhega */
Q3: box-sizing: border-box kya karta hai aur kyun use karte hain?
Answer:
Default (content-box): Width sirf content ke liyeред Padding aur border alag se add hote hainред
border-box: Width mein padding aur border included hote hainред

Border-box use karne se width calculate karna easy ho jata haiред Agar aap 200px width dete ho to element exactly 200px ka hoga, chahe padding aur border kitna bhi hoред

Example:
/* Without border-box */ div { width: 200px; padding: 20px; border: 5px; } /* Total = 200 + 40 + 10 = 250px */ /* With border-box */ div { width: 200px; padding: 20px; border: 5px; box-sizing: border-box; } /* Total = 200px (padding aur border included) */
Best Practice: * { box-sizing: border-box; }
Q4: Block, Inline, aur Inline-Block display mein kya difference hai?
Answer:
Block:
- рдкреВрд░реА width рд▓реЗрддрд╛ рд╣реИ
- рдирдИ line рд╕реЗ рд╢реБрд░реВ рд╣реЛрддрд╛ рд╣реИ
- Width/height set kar sakte hain
- Example: div, p, h1

Inline:
- рд╕рд┐рд░реНрдл рдЬрд┐рддрдиреА width рдЪрд╛рд╣рд┐рдП
- рдПрдХ рд╣реА line рдкрд░ рд░рд╣рддреЗ рд╣реИрдВ
- Width/height set рдирд╣реАрдВ рдХрд░ рд╕рдХрддреЗ
- Example: span, a, strong

Inline-Block:
- рдПрдХ рд╣реА line рдкрд░ рд░рд╣рддреЗ рд╣реИрдВ
- Width/height set рдХрд░ рд╕рдХрддреЗ рд╣реИрдВ
- Best of both worlds
- Example: buttons, badges

Inline-block sabse versatile hai - line mein bhi reh sakte ho aur size bhi control kar sakte hoред

ЁЯОи Day 10: Colors, Backgrounds & Units

CSS Colors

CSS рдореЗрдВ colors рдХреЛ 5 рддрд░реАрдХреЛрдВ рд╕реЗ define рдХрд░ рд╕рдХрддреЗ рд╣реИрдВред рд╕реЛрдЪреЛ - рдПрдХ painter рдХреЗ рдкрд╛рд╕ рдЕрд▓рдЧ-рдЕрд▓рдЧ рддрд░реАрдХреЗ рд╣реИрдВ colors mix рдХрд░рдиреЗ рдХреЗ!
1. Color Names (140+ predefined)
color: red; color: blue; color: tomato; color: dodgerblue;
red
blue
tomato
dodgerblue
2. Hexadecimal (#RRGGBB)

6 digits: Red, Green, Blue (00 to FF)

color: #FF0000; /* Red */ color: #00FF00; /* Green */ color: #0000FF; /* Blue */ color: #667eea; /* Custom purple */
#FF0000
#00FF00
#0000FF
#667eea
3. RGB (Red, Green, Blue)

Values: 0 to 255

color: rgb(255, 0, 0); /* Red */ color: rgb(0, 255, 0); /* Green */ color: rgb(0, 0, 255); /* Blue */ color: rgb(102, 126, 234); /* Custom */
rgb(255,0,0)
rgb(0,255,0)
rgb(0,0,255)
rgb(102,126,234)
4. RGBA (RGB + Alpha/Transparency)

Alpha: 0 (transparent) to 1 (opaque)

color: rgba(255, 0, 0, 1); /* Fully opaque */ color: rgba(255, 0, 0, 0.5); /* 50% transparent */ color: rgba(255, 0, 0, 0.2); /* 80% transparent */
Alpha: 1
Alpha: 0.7
Alpha: 0.4
Alpha: 0.1
5. HSL (Hue, Saturation, Lightness)

Hue: 0-360 (color wheel), Saturation: 0-100%, Lightness: 0-100%

color: hsl(0, 100%, 50%); /* Red */ color: hsl(120, 100%, 50%); /* Green */ color: hsl(240, 100%, 50%); /* Blue */ color: hsla(240, 100%, 50%, 0.5); /* Blue with transparency */
hsl(0,100%,50%)
hsl(120,100%,50%)
hsl(240,100%,50%)
hsl(280,70%,65%)
Background Color
background-color: #667eea; background-color: rgba(102, 126, 234, 0.5);
Background Color Example
Background Image
background-image: url('image.jpg'); background-repeat: no-repeat; /* repeat, repeat-x, repeat-y */ background-size: cover; /* contain, 100px, 50% */ background-position: center; /* top, bottom, left, right */
Linear Gradient
background: linear-gradient(to right, #667eea, #764ba2); background: linear-gradient(45deg, red, blue); background: linear-gradient(to bottom, #667eea 0%, #764ba2 100%);
Linear Gradient Example
Radial Gradient
background: radial-gradient(circle, #667eea, #764ba2); background: radial-gradient(ellipse at top, red, blue);
Radial Gradient Example
1. Absolute Units

px (Pixels): Fixed sizeред Screen рдкрд░ exact sizeред

width: 200px; font-size: 16px; padding: 20px;

Pixels fixed hote hain - screen size change hone par bhi same size rahengeред Responsive design ke liye best nahiред

2. Relative Units (Responsive рдХреЗ рд▓рд┐рдП)

% (Percentage): Parent element рдХреЗ relativeред

width: 50%; /* Parent ka 50% */ padding: 10%; /* Parent width ka 10% */
50% width

em: Parent element рдХреЗ font-size рдХреЗ relativeред

/* Parent font-size: 16px */ font-size: 2em; /* 32px (16 * 2) */ padding: 1.5em; /* 24px (16 * 1.5) */

тЪая╕П Problem: Nested elements рдореЗрдВ compound рд╣реЛ рдЬрд╛рддрд╛ рд╣реИред

rem (Root em - рд╕рдмрд╕реЗ рдЕрдЪреНрдЫрд╛!): Root element (html) рдХреЗ font-size рдХреЗ relativeред

/* Root font-size: 16px */ font-size: 2rem; /* 32px */ padding: 1.5rem; /* 24px */ margin: 2rem; /* 32px */

тЬЕ Benefit: Consistent sizingред Nesting рд╕реЗ affect рдирд╣реАрдВ рд╣реЛрддрд╛ред

vh (Viewport Height): Screen height рдХрд╛ percentageред

height: 100vh; /* Full screen height */ height: 50vh; /* Half screen height */

vw (Viewport Width): Screen width рдХрд╛ percentageред

width: 100vw; /* Full screen width */ width: 50vw; /* Half screen width */ font-size: 5vw; /* Responsive font */
ЁЯТб Best Practices:
- Font sizes рдХреЗ рд▓рд┐рдП: rem use рдХрд░реЛ
- Padding/Margin рдХреЗ рд▓рд┐рдП: rem рдпрд╛ px
- Width/Height рдХреЗ рд▓рд┐рдП: % рдпрд╛ vw/vh
- Full-screen sections рдХреЗ рд▓рд┐рдП: 100vh
- Responsive typography рдХреЗ рд▓рд┐рдП: vw + rem

ЁЯТ╝ Interview Questions - Day 10

Q1: RGB aur RGBA mein kya difference hai?
Answer:
RGB: Red, Green, Blue - рддреАрди colors mix рдХрд░рдХреЗ рдХреЛрдИ рднреА color рдмрдирд╛рддреЗ рд╣реИрдВред Values 0-255ред
RGBA: RGB + Alpha (transparency)ред Alpha value 0 (рдкреВрд░рд╛ transparent) рд╕реЗ 1 (рдкреВрд░рд╛ opaque) рддрдХред

RGBA use karte hain jab element ko semi-transparent banana hoред Jaise overlays, modals, hover effects meinред

Example:
background: rgb(255, 0, 0); /* Solid red */ background: rgba(255, 0, 0, 0.5); /* 50% transparent red */
Q2: px, em, rem, aur % units mein kya difference hai?
Answer:
px (Pixels): Fixed unitред Responsive рдирд╣реАрдВред Exact sizeред
em: Parent element рдХреЗ font-size рдХреЗ relativeред Nesting рдореЗрдВ compound рд╣реЛрддрд╛ рд╣реИред
rem: Root (html) element рдХреЗ font-size рдХреЗ relativeред Consistent sizingред
%: Parent element рдХреЗ size рдХреЗ relativeред

Modern websites mein rem sabse zyada use hota hai kyunki consistent aur predictable haiред Percentage width/height ke liye best haiред

Example:
/* Root font-size: 16px */ font-size: 16px; /* Fixed */ font-size: 1em; /* Parent ke equal */ font-size: 1rem; /* 16px (root ke equal) */ width: 50%; /* Parent ka 50% */
Q3: vh aur vw units ka kya use hai?
Answer:
vh (Viewport Height): Screen/browser window рдХреА height рдХрд╛ percentageред
vw (Viewport Width): Screen/browser window рдХреА width рдХрд╛ percentageред

Yeh units responsive design ke liye bahut useful hainред Screen size change hone par automatically adjust ho jate hainред

Common Uses:
- 100vh: Full-screen hero sections
- 100vw: Full-width containers
- 5vw: Responsive font sizes

Example:
/* Hero section */ .hero { height: 100vh; /* Full screen height */ width: 100vw; /* Full screen width */ } /* Responsive heading */ h1 { font-size: 5vw; } /* Screen width ke according */
Q4: Linear gradient aur Radial gradient mein kya difference hai?
Answer:
Linear Gradient: Colors рдПрдХ рд╕реАрдзреА line рдореЗрдВ transition рдХрд░рддреЗ рд╣реИрдВред Direction specify рдХрд░ рд╕рдХрддреЗ рд╣реЛ (top, bottom, left, right, diagonal)ред
Radial Gradient: Colors center рд╕реЗ рдмрд╛рд╣рд░ рдХреА рдУрд░ circular/elliptical pattern рдореЗрдВ transition рдХрд░рддреЗ рд╣реИрдВред

Linear gradient buttons, headers, backgrounds ke liye use hota haiред Radial gradient spotlight effects, circular designs ke liyeред

Example:
/* Linear - left to right */ background: linear-gradient(to right, red, blue); /* Linear - diagonal */ background: linear-gradient(45deg, red, blue); /* Radial - center se bahar */ background: radial-gradient(circle, red, blue);

тЬНя╕П Day 11: Fonts, Typography & Icons

Typography

Typography рдорддрд▓рдм text рдХреЛ beautiful рдФрд░ readable рдмрдирд╛рдирд╛ред рд╕реЛрдЪреЛ - рдПрдХ book рдореЗрдВ рдЕрд▓рдЧ-рдЕрд▓рдЧ fonts, sizes, spacing рд╣реЛрддреА рд╣реИ рдЬреЛ reading experience рдХреЛ better рдмрдирд╛рддреА рд╣реИ!
font-family (Font рдХрд╛ рдирд╛рдо)
/* Single font */ font-family: Arial; /* Font stack (fallback) */ font-family: 'Helvetica Neue', Arial, sans-serif; /* Generic families */ font-family: serif; /* Times New Roman style */ font-family: sans-serif; /* Arial style */ font-family: monospace; /* Code style */ font-family: cursive; /* Handwriting style */

Serif Font - Traditional look

Sans-serif Font - Modern look

Monospace Font - Code style

Cursive Font - Handwriting

font-size (Text рдХрд╛ size)
font-size: 16px; /* Fixed */ font-size: 1rem; /* Relative to root */ font-size: 1.5em; /* Relative to parent */ font-size: 2vw; /* Responsive */

12px - Small text

16px - Normal text

24px - Large text

32px - Heading size

font-weight (Text рдХреА thickness)
font-weight: normal; /* 400 */ font-weight: bold; /* 700 */ font-weight: 100; /* Thin */ font-weight: 900; /* Extra bold */

100 - Thin

400 - Normal

700 - Bold

900 - Extra Bold

font-style (Text рдХрд╛ style)
font-style: normal; font-style: italic; font-style: oblique;

Normal text

Italic text

Oblique text

text-align (Text рдХреА alignment)
text-align: left; text-align: center; text-align: right; text-align: justify;

Left aligned text

Center aligned text

Right aligned text

Justified text spreads evenly across the line. This is commonly used in newspapers and books.

text-decoration (Text рдХреА decoration)
text-decoration: none; /* Remove underline from links */ text-decoration: underline; text-decoration: overline; text-decoration: line-through;

No decoration

Underline text

Overline text

Line-through text

text-transform (Text рдХрд╛ case)
text-transform: uppercase; text-transform: lowercase; text-transform: capitalize;

uppercase text

LOWERCASE TEXT

capitalize each word

line-height (Lines рдХреЗ рдмреАрдЪ рдХреА space)
line-height: 1; /* Tight */ line-height: 1.5; /* Normal */ line-height: 2; /* Loose */

Line height 1 - This text has tight spacing between lines. It's harder to read when there are multiple lines.

Line height 1.5 - This is the recommended spacing. It's comfortable to read and looks professional.

Line height 2 - This text has loose spacing. Good for emphasis but can look too spread out.

letter-spacing (Letters рдХреЗ рдмреАрдЪ рдХреА space)
letter-spacing: normal; letter-spacing: 2px; letter-spacing: -1px;

Normal spacing

Increased spacing

Wide spacing

word-spacing (Words рдХреЗ рдмреАрдЪ рдХреА space)
word-spacing: normal; word-spacing: 10px; word-spacing: 20px;

Normal word spacing in this sentence

Increased word spacing in this sentence

Wide word spacing in this sentence

How to Use Google Fonts

Step 1: Go to fonts.google.com

Step 2: Select a font (e.g., Roboto, Open Sans, Poppins)

Step 3: Copy the link tag

<!-- In HTML head --> <link href="https://fonts.googleapis.com/css2?family=Roboto:wght@400;700&display=swap" rel="stylesheet"> <!-- In CSS --> body { font-family: 'Roboto', sans-serif; }

Google Fonts free hain aur bahut zyada variety haiред Professional websites mein mostly Google Fonts hi use hote hainред

ЁЯТб Popular Google Fonts:
- Roboto (Modern, clean)
- Open Sans (Readable, friendly)
- Poppins (Geometric, modern)
- Montserrat (Bold, stylish)
- Lato (Professional, versatile)
Font Awesome Icons

Step 1: Include Font Awesome CDN

<!-- In HTML head --> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css"> <!-- Use icons --> <i class="fas fa-home"></i> Home <i class="fas fa-user"></i> User <i class="fas fa-heart"></i> Like <i class="fas fa-shopping-cart"></i> Cart
Material Icons (Google)
<!-- In HTML head --> <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet"> <!-- Use icons --> <span class="material-icons">home</span> <span class="material-icons">favorite</span> <span class="material-icons">shopping_cart</span>
ЁЯТб Icon Usage:
- Buttons рдореЗрдВ icons add рдХрд░рдирд╛
- Navigation menu рдореЗрдВ
- Social media links
- Feature highlights
- Loading indicators

ЁЯТ╝ Interview Questions - Day 11

Q1: font-family mein fallback fonts kyun use karte hain?
Answer:
Fallback fonts рдПрдХ backup system рд╣реИред рдЕрдЧрд░ рдкрд╣рд▓рд╛ font load рдирд╣реАрдВ рд╣реЛрддрд╛ рдпрд╛ user рдХреЗ system рдореЗрдВ рдирд╣реАрдВ рд╣реИ, рддреЛ browser рдЕрдЧрд▓рд╛ font try рдХрд░рддрд╛ рд╣реИред

Hamesha font stack use karo - specific font, similar font, generic familyред Isse ensure hota hai ki text hamesha readable raheред

Example:
font-family: 'Roboto', 'Helvetica Neue', Arial, sans-serif; /* 1. Roboto (custom) 2. Helvetica Neue (similar) 3. Arial (common) 4. sans-serif (generic fallback) */
Q2: line-height ka kya use hai aur ideal value kya hoti hai?
Answer:
Line-height lines рдХреЗ рдмреАрдЪ рдХреА vertical space control рдХрд░рддрд╛ рд╣реИред рдпрд╣ readability рдХреЗ рд▓рд┐рдП рдмрд╣реБрдд important рд╣реИред

Agar line-height kam hai to text cramped lagta haiред Agar zyada hai to disconnected lagta haiред Ideal value 1.5 to 1.6 hoti hai body text ke liyeред

Best Practices:
- Body text: 1.5 to 1.6
- Headings: 1.2 to 1.3
- Small text: 1.4

Example:
body { line-height: 1.6; /* Comfortable reading */ } h1, h2, h3 { line-height: 1.2; /* Tighter for headings */ }
Q3: Google Fonts kaise use karte hain aur kyun?
Answer:
Google Fonts free, high-quality fonts provide karta рд╣реИ рдЬреЛ easily integrate рд╣реЛ рдЬрд╛рддреЗ рд╣реИрдВред

Steps:
1. fonts.google.com рдкрд░ рдЬрд╛рдУ
2. Font select рдХрд░реЛ
3. Link tag copy рдХрд░реЛ
4. HTML head рдореЗрдВ paste рдХрд░реЛ
5. CSS рдореЗрдВ font-family use рдХрд░реЛ

Google Fonts use karne se website professional dikhti haiред System fonts se better variety milti hai aur cross-browser compatible hote hainред

Example:
<!-- HTML --> <link href="https://fonts.googleapis.com/css2?family=Poppins:wght@400;600;700&display=swap" rel="stylesheet"> /* CSS */ body { font-family: 'Poppins', sans-serif; }
Q4: text-transform aur text-decoration ka kya use hai?
Answer:
text-transform: Text рдХрд╛ case change рдХрд░рддрд╛ рд╣реИ (uppercase, lowercase, capitalize)ред
text-decoration: Text рдкрд░ lines add рдХрд░рддрд╛ рд╣реИ (underline, overline, line-through)ред

Text-transform buttons, headings, labels ke liye use hota haiред Text-decoration links se underline hatane ya strikethrough price dikhane ke liyeред

Example:
/* Uppercase button text */ button { text-transform: uppercase; } /* Remove link underline */ a { text-decoration: none; } /* Strikethrough old price */ .old-price { text-decoration: line-through; }

ЁЯУН Day 12: CSS Positioning & Z-index

CSS Positioning

Positioning рдмрддрд╛рддрд╛ рд╣реИ рдХрд┐ elements page рдкрд░ рдХрд╣рд╛рдБ рд░рд╣реЗрдВрдЧреЗред рд╕реЛрдЪреЛ - рдПрдХ room рдореЗрдВ furniture рдХреЛ рдЕрд▓рдЧ-рдЕрд▓рдЧ рддрд░реАрдХреЛрдВ рд╕реЗ arrange рдХрд░ рд╕рдХрддреЗ рд╣реЛ!
1. position: static (Default)

Normal document flow рдореЗрдВ рд░рд╣рддрд╛ рд╣реИред top, right, bottom, left рдХрд╛рдо рдирд╣реАрдВ рдХрд░рддреЗред

div { position: static; /* Default */ }

Yeh default behavior haiред Elements ek ke baad ek aate hain jaise HTML mein likhe hainред

2. position: relative

рдЕрдкрдиреА original position рдХреЗ relative move рд╣реЛрддрд╛ рд╣реИред Space reserved рд░рд╣рддреА рд╣реИред

div { position: relative; top: 20px; /* Original position рд╕реЗ 20px рдиреАрдЪреЗ */ left: 30px; /* Original position рд╕реЗ 30px рджрд╛рдПрдВ */ }
Box 1
Box 2 (relative - moved)
Box 3

Relative positioning se element move hota hai lekin uski original jagah reserved rehti haiред Dusre elements affect nahi hoteред

3. position: absolute

Nearest positioned parent рдХреЗ relative position рд╣реЛрддрд╛ рд╣реИред Document flow рд╕реЗ рд╣рдЯ рдЬрд╛рддрд╛ рд╣реИред

/* Parent */ .container { position: relative; /* Reference point */ } /* Child */ .box { position: absolute; top: 20px; /* Parent рдХреЗ top рд╕реЗ 20px */ right: 30px; /* Parent рдХреЗ right рд╕реЗ 30px */ }

Parent Container (position: relative)

Absolute Box

Absolute positioning se element document flow se bahar ho jata haiред Yeh parent ke andar kahi bhi place ho sakta haiред Modals, dropdowns, tooltips ke liye use hota haiред

4. position: fixed

Viewport (screen) рдХреЗ relative fixed рд░рд╣рддрд╛ рд╣реИред Scroll рдХрд░рдиреЗ рдкрд░ bhi same рдЬрдЧрд╣ рд░рд╣рддрд╛ рд╣реИред

div { position: fixed; top: 0; /* Screen рдХреЗ top рдкрд░ */ left: 0; width: 100%; }

Real-world examples:

  • Fixed navigation bar (scroll рдХрд░рдиреЗ рдкрд░ bhi top рдкрд░ рд░рд╣реЗ)
  • Floating action button (bottom-right corner рдореЗрдВ)
  • Cookie consent banner (bottom рдкрд░ fixed)
  • Chat widget (bottom-right рдореЗрдВ fixed)

Fixed elements hamesha screen par ek hi jagah dikhte hain, chahe aap kitna bhi scroll karoред Navbar, chat buttons ke liye perfectред

5. position: sticky

Relative рдФрд░ fixed рдХрд╛ combinationред Scroll рдХрд░рдиреЗ рдкрд░ рдПрдХ point рдкрд░ fixed рд╣реЛ рдЬрд╛рддрд╛ рд╣реИред

div { position: sticky; top: 0; /* Scroll рдХрд░рдиреЗ рдкрд░ top рдкрд░ stick рд╣реЛ рдЬрд╛рдПрдЧрд╛ */ }

Real-world examples:

  • Table headers (scroll рдХрд░рдиреЗ рдкрд░ top рдкрд░ stick рд╣реЛ рдЬрд╛рдПрдВ)
  • Section headings
  • Sidebar navigation

Sticky positioning bahut useful haiред Pehle normal flow mein rehta hai, phir scroll karne par fixed ho jata haiред Table headers ke liye bestред

What is Z-index?

Z-index рдмрддрд╛рддрд╛ рд╣реИ рдХрд┐ elements рдХреМрди рд╕реА layer рдкрд░ рд╣реИрдВред Higher value = рдКрдкрд░ рдХреА layerред

/* Lower z-index - рдкреАрдЫреЗ */ .box1 { position: relative; z-index: 1; } /* Higher z-index - рдЖрдЧреЗ */ .box2 { position: relative; z-index: 10; }
Z-index: 1
(рдкреАрдЫреЗ)
Z-index: 10
(рдЖрдЧреЗ)

Z-index sirf positioned elements (relative, absolute, fixed, sticky) par kaam karta haiред Static elements par nahiред

ЁЯТб Common Z-index Values:
- Normal content: 1-10
- Dropdowns: 100-500
- Modals/Overlays: 1000-5000
- Tooltips: 10000+
- Fixed navbar: 100-1000
Float: left / right

Element рдХреЛ left рдпрд╛ right side рдкрд░ float рдХрд░рддрд╛ рд╣реИред Text wrap рд╣реЛ рдЬрд╛рддрд╛ рд╣реИред

img { float: left; margin-right: 20px; } /* Clear float */ .clearfix::after { content: ""; display: table; clear: both; }

рдпрд╣ text float рдХрд┐рдП рдЧрдП box рдХреЗ рдЪрд╛рд░реЛрдВ рдУрд░ wrap рд╣реЛ рд░рд╣рд╛ рд╣реИред Float property рдкрд╣рд▓реЗ layouts рдмрдирд╛рдиреЗ рдХреЗ рд▓рд┐рдП use рд╣реЛрддреА рдереА, рд▓реЗрдХрд┐рди рдЕрдм Flexbox рдФрд░ Grid рдмреЗрд╣рддрд░ options рд╣реИрдВред Float рдЕрдм mostly images рдХреЗ рд╕рд╛рде text wrap рдХрд░рдиреЗ рдХреЗ рд▓рд┐рдП use рд╣реЛрддрд╛ рд╣реИред

Float purana method haiред Ab Flexbox aur Grid use karte hain layouts ke liyeред Float sirf images ke saath text wrap karne ke liye use hota haiред

ЁЯТ╝ Interview Questions - Day 12

Q1: Relative aur Absolute positioning mein kya difference hai?
Answer:
Relative:
- рдЕрдкрдиреА original position рдХреЗ relative move рд╣реЛрддрд╛ рд╣реИ
- Document flow рдореЗрдВ рд░рд╣рддрд╛ рд╣реИ (space reserved)
- рджреВрд╕рд░реЗ elements affect рдирд╣реАрдВ рд╣реЛрддреЗ

Absolute:
- Nearest positioned parent рдХреЗ relative position рд╣реЛрддрд╛ рд╣реИ
- Document flow рд╕реЗ рдмрд╛рд╣рд░ рд╣реЛ рдЬрд╛рддрд╛ рд╣реИ (no space reserved)
- рджреВрд╕рд░реЗ elements overlap рд╣реЛ рд╕рдХрддреЗ рд╣реИрдВ

Relative positioning se element thoda move hota hai lekin jagah reserved rehti haiред Absolute positioning se element completely flow se bahar ho jata hai aur parent ke andar kahi bhi place ho sakta haiред

Example:
/* Relative - slight adjustment */ .button { position: relative; top: 5px; /* Thoda neeche */ } /* Absolute - complete control */ .dropdown { position: absolute; top: 100%; /* Parent ke neeche */ left: 0; }
Q2: Fixed aur Sticky positioning mein kya difference hai?
Answer:
Fixed:
- Viewport (screen) рдХреЗ relative fixed рд░рд╣рддрд╛ рд╣реИ
- рд╣рдореЗрд╢рд╛ same position рдкрд░ (scroll рдХрд░рдиреЗ рдкрд░ рднреА)
- Document flow рд╕реЗ completely рдмрд╛рд╣рд░

Sticky:
- Pehle normal flow рдореЗрдВ, рдлрд┐рд░ scroll рдкрд░ fixed
- Parent container рдХреЗ рдЕрдВрджрд░ рд╣реА stick рд╣реЛрддрд╛ рд╣реИ
- Hybrid behavior (relative + fixed)

Fixed navbar hamesha screen par dikhta haiред Sticky header pehle normal rehta hai, scroll karne par top par stick ho jata haiред Sticky parent container ke andar hi kaam karta haiред

Use Cases:
- Fixed: Navbar, chat button, cookie banner
- Sticky: Table headers, section headings
Q3: Z-index kya hai aur kab use hota hai?
Answer:
Z-index elements рдХреА stacking order control рдХрд░рддрд╛ рд╣реИред Higher value рд╡рд╛рд▓рд╛ element рдКрдкрд░ рдХреА layer рдкрд░ рд╣реЛрддрд╛ рд╣реИред

Important Points:
- Sirf positioned elements рдкрд░ рдХрд╛рдо рдХрд░рддрд╛ рд╣реИ (relative, absolute, fixed, sticky)
- Static elements рдкрд░ рдХрд╛рдо рдирд╣реАрдВ рдХрд░рддрд╛
- Negative values рднреА рд╣реЛ рд╕рдХрддреА рд╣реИрдВ
- Parent-child relationship matter рдХрд░рддреА рд╣реИ

Z-index tab use hota hai jab elements overlap ho rahe hain aur aapko decide karna hai ki kaun sa element upar dikhegaред Modals, dropdowns, tooltips mein bahut use hota haiред

Example:
/* Navbar */ .navbar { position: fixed; z-index: 100; } /* Modal overlay */ .modal-overlay { position: fixed; z-index: 1000; } /* Modal content */ .modal { position: fixed; z-index: 1001; }
Q4: Float property ka kya use hai aur ab kyun kam use hoti hai?
Answer:
Float property elements рдХреЛ left рдпрд╛ right side рдкрд░ float рдХрд░рддреА рд╣реИ рдФрд░ text рдХреЛ wrap рдХрд░рддреА рд╣реИред

Pehle: Layouts рдмрдирд╛рдиреЗ рдХреЗ рд▓рд┐рдП float use рд╣реЛрддрд╛ рдерд╛ (columns, grids)
Ab: Flexbox рдФрд░ Grid рдмреЗрд╣рддрд░ options рд╣реИрдВ layouts рдХреЗ рд▓рд┐рдП

Float ab mostly images ke saath text wrap karne ke liye use hota haiред Layouts ke liye Flexbox aur Grid modern aur powerful hainред Float se bahut saari problems thi jaise parent collapse, clearing issuesред

Modern Alternative:
/* Old way - Float */ .column { float: left; width: 50%; } /* Modern way - Flexbox */ .container { display: flex; } .column { flex: 1; }

ЁЯУР Day 13: Flexbox (Modern Layout)

What is Flexbox?

Flexbox рдПрдХ modern layout system рд╣реИ рдЬреЛ elements рдХреЛ flexible рдФрд░ responsive рддрд░реАрдХреЗ рд╕реЗ arrange рдХрд░рддрд╛ рд╣реИред рд╕реЛрдЪреЛ - рдПрдХ elastic band рдЬреЛ stretch рдФрд░ shrink рд╣реЛ рд╕рдХрддрд╛ рд╣реИ!
ЁЯОп Why Flexbox?
  • Easy alignment (center, space-between, etc.)
  • Responsive layouts without media queries
  • Equal height columns automatically
  • Reordering elements without changing HTML
  • Better than float and positioning
display: flex

Container рдХреЛ flex container рдмрдирд╛рддрд╛ рд╣реИред Direct children flex items рдмрди рдЬрд╛рддреЗ рд╣реИрдВред

.container { display: flex; }
Item 1
Item 2
Item 3
flex-direction (Main axis рдХреА direction)
flex-direction: row; /* Default - left to right */ flex-direction: row-reverse; /* Right to left */ flex-direction: column; /* Top to bottom */ flex-direction: column-reverse; /* Bottom to top */

row (Default):

1
2
3

column:

1
2
3
justify-content (Main axis рдкрд░ alignment)
justify-content: flex-start; /* Start рд╕реЗ */ justify-content: flex-end; /* End рд╕реЗ */ justify-content: center; /* Center рдореЗрдВ */ justify-content: space-between; /* Equal space between */ justify-content: space-around; /* Equal space around */ justify-content: space-evenly; /* Perfectly equal space */

flex-start:

1
2
3

center:

1
2
3

space-between:

1
2
3

space-evenly:

1
2
3
align-items (Cross axis рдкрд░ alignment)
align-items: stretch; /* Default - full height */ align-items: flex-start; /* Top */ align-items: flex-end; /* Bottom */ align-items: center; /* Center */ align-items: baseline; /* Text baseline */

center (Perfect centering!):

Perfectly Centered!
flex-wrap (Wrapping control)
flex-wrap: nowrap; /* Default - single line */ flex-wrap: wrap; /* Multiple lines */ flex-wrap: wrap-reverse; /* Reverse order */

wrap (Responsive!):

1
2
3
4
5
gap (Space between items)
gap: 20px; /* All sides */ gap: 10px 20px; /* Row gap, Column gap */ row-gap: 10px; column-gap: 20px;
Item 1
Item 2
Item 3
flex-grow (Extra space рд▓реЗрдиреЗ рдХреА ability)
.item { flex-grow: 1; /* Equal distribution */ } .item-large { flex-grow: 2; /* Double space */ }
flex-grow: 1
flex-grow: 2 (Double!)
flex-grow: 1
flex-shrink (Shrink рд╣реЛрдиреЗ рдХреА ability)
.item { flex-shrink: 1; /* Can shrink */ } .item-fixed { flex-shrink: 0; /* Won't shrink */ }
flex-basis (Initial size)
.item { flex-basis: 200px; /* Starting width */ flex-basis: 30%; /* Percentage */ flex-basis: auto; /* Content size */ }
flex (Shorthand - рд╕рдмрд╕реЗ common!)
/* flex: grow shrink basis */ flex: 1; /* flex: 1 1 0 - Equal distribution */ flex: 2; /* flex: 2 1 0 - Double space */ flex: 0 0 200px; /* Fixed 200px width */ flex: 1 0 auto; /* Grow but don't shrink */
flex: 1
flex: 1
flex: 2
align-self (Individual alignment)
.item { align-self: flex-start; align-self: flex-end; align-self: center; align-self: stretch; }
Normal
align-self: center
Normal
1. Perfect Centering
.container { display: flex; justify-content: center; align-items: center; height: 100vh; }
Perfectly Centered!
2. Navigation Bar
.navbar { display: flex; justify-content: space-between; align-items: center; }
Logo
Home About Contact
3. Card Grid (Responsive)
.grid { display: flex; flex-wrap: wrap; gap: 20px; } .card { flex: 1 1 300px; /* Min 300px, then grow */ }
Card 1
Card 2
Card 3
4. Sidebar Layout
.container { display: flex; } .sidebar { flex: 0 0 250px; /* Fixed 250px */ } .main { flex: 1; /* Take remaining space */ }
Sidebar
(Fixed 150px)
Main Content
(Flexible)

ЁЯТ╝ Interview Questions - Day 13

Q1: Flexbox kya hai aur traditional layouts se kaise better hai?
Answer:
Flexbox рдПрдХ modern CSS layout module рд╣реИ рдЬреЛ elements рдХреЛ flexible рдФрд░ responsive рддрд░реАрдХреЗ рд╕реЗ arrange рдХрд░рддрд╛ рд╣реИред

Traditional (Float/Position) vs Flexbox:
- Float: Complex, clearing issues, not intuitive
- Flexbox: Simple, powerful, intuitive

Flexbox se layouts banana bahut easy ho gaya haiред Centering, equal heights, responsive grids - sab kuch simple ho gayaред Float aur positioning se bahut better haiред

Benefits:
- Perfect centering (vertical + horizontal)
- Equal height columns automatically
- Responsive without media queries
- Reordering without changing HTML
- Better browser support
Q2: justify-content aur align-items mein kya difference hai?
Answer:
justify-content: Main axis (default: horizontal) рдкрд░ alignment control рдХрд░рддрд╛ рд╣реИред
align-items: Cross axis (default: vertical) рдкрд░ alignment control рдХрд░рддрд╛ рд╣реИред

Agar flex-direction row hai to justify-content horizontal alignment control karega aur align-items verticalред Agar flex-direction column hai to ulta ho jayegaред

Perfect Centering:
.container { display: flex; justify-content: center; /* Horizontal center */ align-items: center; /* Vertical center */ height: 100vh; }
Common Values:
- justify-content: flex-start, center, space-between, space-evenly
- align-items: flex-start, center, flex-end, stretch
Q3: flex: 1 ka kya matlab hai?
Answer:
flex: 1 рдПрдХ shorthand property рд╣реИ рдЬреЛ рддреАрди values set рдХрд░рддреА рд╣реИ:
- flex-grow: 1 (extra space рд▓реЗ рд╕рдХрддрд╛ рд╣реИ)
- flex-shrink: 1 (shrink рд╣реЛ рд╕рдХрддрд╛ рд╣реИ)
- flex-basis: 0 (starting size 0)

flex: 1 ka matlab hai ki element available space ko equally distribute karegaред Agar teen items hain aur sabko flex: 1 diya to teeno equal width lengeред

Example:
/* Equal width columns */ .item { flex: 1; /* All items equal */ } /* One item double width */ .item-large { flex: 2; /* Double space */ } /* Fixed width item */ .item-fixed { flex: 0 0 200px; /* Fixed 200px */ }
Q4: Flexbox se responsive layout kaise banate hain?
Answer:
Flexbox naturally responsive рд╣реИред flex-wrap: wrap use рдХрд░рдХреЗ items automatically next line рдкрд░ рдЪрд▓реЗ рдЬрд╛рддреЗ рд╣реИрдВред

flex-wrap: wrap use karne se items screen size ke according adjust ho jate hainред Agar jagah kam hai to next line par chale jayengeред Media queries ki zarurat kam pad jati haiред

Responsive Card Grid:
.container { display: flex; flex-wrap: wrap; gap: 20px; } .card { flex: 1 1 300px; /* Min 300px, then grow */ /* Screen chhoti hogi to wrap ho jayega */ } /* Mobile: 1 column Tablet: 2 columns Desktop: 3+ columns Automatically! */
Key Properties:
- flex-wrap: wrap (wrapping enable)
- flex: 1 1 300px (min-width with flexibility)
- gap: 20px (spacing between items)

ЁЯЪА Day 14: Week 2 Project & Summary

Week 2 Complete! ЁЯОЙ

рдЖрдкрдиреЗ CSS рдХреЗ рд╕рднреА important concepts рд╕реАрдЦ рд▓рд┐рдП рд╣реИрдВред рдЕрдм рдЗрди рд╕рдмрдХреЛ рдПрдХ рд╕рд╛рде use рдХрд░рдХреЗ рдПрдХ complete responsive webpage рдмрдирд╛рдПрдВрдЧреЗ!
ЁЯУЪ What You Learned This Week:
  • Day 8: CSS Basics, Selectors, Ways to Apply CSS
  • Day 9: Box Model, Padding, Margin, Border, Display Types
  • Day 10: Colors (RGB, RGBA, HSL), Backgrounds, Units (px, rem, vh, vw)
  • Day 11: Typography, Fonts, Google Fonts, Icons
  • Day 12: Positioning (relative, absolute, fixed, sticky), Z-index
  • Day 13: Flexbox (complete layout system)
Project Requirements
  • тЬЕ Fixed navigation bar with logo and menu
  • тЬЕ Hero section with centered content (Flexbox)
  • тЬЕ Features section with cards (Flexbox grid)
  • тЬЕ Responsive design (flex-wrap)
  • тЬЕ Custom colors and gradients
  • тЬЕ Google Fonts
  • тЬЕ Icons (Font Awesome)
  • тЬЕ Proper spacing (margin, padding)
  • тЬЕ Hover effects
  • тЬЕ Footer with social links
Complete HTML + CSS Code
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Modern Landing Page</title> <!-- Google Fonts --> <link href="https://fonts.googleapis.com/css2?family=Poppins:wght@400;600;700&display=swap" rel="stylesheet"> <!-- Font Awesome --> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css"> <style> * { margin: 0; padding: 0; box-sizing: border-box; } body { font-family: 'Poppins', sans-serif; line-height: 1.6; color: #333; } /* Navigation */ .navbar { position: fixed; top: 0; width: 100%; background: white; box-shadow: 0 2px 10px rgba(0,0,0,0.1); z-index: 1000; } .nav-container { display: flex; justify-content: space-between; align-items: center; max-width: 1200px; margin: 0 auto; padding: 1rem 2rem; } .logo { font-size: 1.5rem; font-weight: 700; color: #667eea; } .nav-menu { display: flex; gap: 2rem; list-style: none; } .nav-menu a { text-decoration: none; color: #333; font-weight: 600; transition: color 0.3s; } .nav-menu a:hover { color: #667eea; } /* Hero Section */ .hero { display: flex; justify-content: center; align-items: center; min-height: 100vh; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: white; text-align: center; padding: 2rem; margin-top: 60px; } .hero-content h1 { font-size: 3rem; margin-bottom: 1rem; } .hero-content p { font-size: 1.2rem; margin-bottom: 2rem; opacity: 0.9; } .btn { display: inline-block; padding: 1rem 2rem; background: white; color: #667eea; text-decoration: none; border-radius: 50px; font-weight: 600; transition: transform 0.3s, box-shadow 0.3s; } .btn:hover { transform: translateY(-3px); box-shadow: 0 10px 20px rgba(0,0,0,0.2); } /* Features Section */ .features { max-width: 1200px; margin: 4rem auto; padding: 2rem; } .section-title { text-align: center; font-size: 2.5rem; margin-bottom: 3rem; color: #667eea; } .features-grid { display: flex; flex-wrap: wrap; gap: 2rem; } .feature-card { flex: 1 1 300px; background: white; padding: 2rem; border-radius: 10px; box-shadow: 0 5px 15px rgba(0,0,0,0.1); text-align: center; transition: transform 0.3s; } .feature-card:hover { transform: translateY(-10px); } .feature-icon { font-size: 3rem; color: #667eea; margin-bottom: 1rem; } .feature-card h3 { font-size: 1.5rem; margin-bottom: 1rem; } /* Footer */ .footer { background: #333; color: white; text-align: center; padding: 2rem; } .social-links { display: flex; justify-content: center; gap: 1.5rem; margin-top: 1rem; } .social-links a { color: white; font-size: 1.5rem; transition: color 0.3s; } .social-links a:hover { color: #667eea; } /* Responsive */ @media (max-width: 768px) { .hero-content h1 { font-size: 2rem; } .nav-menu { gap: 1rem; } } </style> </head> <body> <!-- Navigation --> <nav class="navbar"> <div class="nav-container"> <div class="logo">MyBrand</div> <ul class="nav-menu"> <li><a href="#home">Home</a></li> <li><a href="#features">Features</a></li> <li><a href="#contact">Contact</a></li> </ul> </div> </nav> <!-- Hero Section --> <section class="hero" id="home"> <div class="hero-content"> <h1>Welcome to the Future</h1> <p>Build amazing websites with modern CSS</p> <a href="#features" class="btn">Get Started</a> </div> </section> <!-- Features Section --> <section class="features" id="features"> <h2 class="section-title">Our Features</h2> <div class="features-grid"> <div class="feature-card"> <i class="fas fa-rocket feature-icon"></i> <h3>Fast Performance</h3> <p>Lightning fast load times for better user experience</p> </div> <div class="feature-card"> <i class="fas fa-mobile-alt feature-icon"></i> <h3>Responsive Design</h3> <p>Works perfectly on all devices and screen sizes</p> </div> <div class="feature-card"> <i class="fas fa-shield-alt feature-icon"></i> <h3>Secure & Reliable</h3> <p>Built with security and reliability in mind</p> </div> </div> </section> <!-- Footer --> <footer class="footer"> <p>© 2024 MyBrand. All rights reserved.</p> <div class="social-links"> <a href="#"><i class="fab fa-facebook"></i></a> <a href="#"><i class="fab fa-twitter"></i></a> <a href="#"><i class="fab fa-instagram"></i></a> <a href="#"><i class="fab fa-linkedin"></i></a> </div> </footer> </body> </html>
ЁЯТб What This Project Demonstrates:
тЬЕ Fixed navbar (position: fixed)
тЬЕ Flexbox centering (hero section)
тЬЕ Responsive grid (flex-wrap)
тЬЕ Gradients (linear-gradient)
тЬЕ Google Fonts (Poppins)
тЬЕ Font Awesome icons
тЬЕ Hover effects (transform, box-shadow)
тЬЕ Box model (padding, margin)
тЬЕ Z-index (navbar on top)
тЬЕ Media queries (responsive)
ЁЯОп CSS Best Practices:
  • Always use box-sizing: border-box
  • Use rem for font sizes (not px)
  • Use Flexbox for layouts (not float)
  • Use external CSS files (not inline)
  • Use meaningful class names (.btn, .card, not .blue-box)
  • Group related styles together
  • Use CSS variables for colors and spacing
  • Mobile-first approach (start with mobile, then desktop)
  • Use gap instead of margin for Flexbox spacing
  • Test on multiple browsers and devices
CSS Variables (Modern Approach)
:root { /* Colors */ --primary-color: #667eea; --secondary-color: #764ba2; --text-color: #333; --bg-color: #f5f5f5; /* Spacing */ --spacing-sm: 0.5rem; --spacing-md: 1rem; --spacing-lg: 2rem; /* Font sizes */ --font-sm: 0.875rem; --font-md: 1rem; --font-lg: 1.5rem; } /* Usage */ .button { background: var(--primary-color); padding: var(--spacing-md); font-size: var(--font-md); }
ЁЯЪА Next Steps (Week 3):
- CSS Grid (advanced layouts)
- Animations & Transitions
- Responsive Design (media queries)
- CSS Transforms
- Advanced Selectors
- CSS Frameworks (Bootstrap, Tailwind)

ЁЯТ╝ Final Interview Questions - Week 2 Revision

Q1: Modern website banane ke liye sabse important CSS concepts kaunse hain?
Answer:
Top 5 Essential Concepts:

1. Box Model: Padding, margin, border рд╕рдордЭрдирд╛ рдЬрд░реВрд░реА рд╣реИред box-sizing: border-box use рдХрд░реЛред

2. Flexbox: Modern layouts рдХреЗ рд▓рд┐рдПред Centering, responsive grids, navigation - рд╕рдм рдХреБрдЫред

3. Positioning: Fixed navbar, modals, dropdowns рдХреЗ рд▓рд┐рдПред Relative, absolute, fixed рд╕рдордЭреЛред

4. Units: rem use рдХрд░реЛ fonts рдХреЗ рд▓рд┐рдП, % рдпрд╛ vw/vh responsive layouts рдХреЗ рд▓рд┐рдПред

5. Colors & Typography: RGBA for transparency, Google Fonts for professional lookред

Yeh 5 concepts master kar lo to aap koi bhi modern website bana sakte hoред Flexbox sabse important hai - isko achhe se practice karoред
Q2: Responsive website banane ke liye kya karna chahiye?
Answer:
Responsive Design Checklist:

1. Viewport Meta Tag: <meta name="viewport" content="width=device-width, initial-scale=1.0">

2. Flexible Units: rem, %, vw, vh use рдХрд░реЛ (px рдирд╣реАрдВ)

3. Flexbox with flex-wrap: Automatic wrapping for different screens

4. Media Queries: Different styles for different screen sizes

5. Mobile-First: Pehle mobile design рдХрд░реЛ, рдлрд┐рд░ desktop

6. Images: max-width: 100% for responsive images

Flexbox aur proper units use karne se bahut kuch automatically responsive ho jata haiред Media queries sirf fine-tuning ke liye use karoред
Q3: CSS performance improve karne ke liye kya karna chahiye?
Answer:
CSS Performance Tips:

1. Minimize CSS: Remove unused styles, minify files

2. Avoid Complex Selectors: .class better than div > ul > li > a

3. Use Shorthand: margin: 10px 20px instead of 4 separate properties

4. Optimize Images: Compress, use appropriate formats

5. Reduce Repaints: Avoid changing layout properties frequently

6. CSS Variables: Reuse values, easier maintenance

Simple selectors use karo, unnecessary styles mat likho, aur images optimize karoред Yeh basic tips follow karne se website fast load hogiред

ЁЯОЙ Congratulations!

рдЖрдкрдиреЗ Week 2 successfully complete рдХрд░ рд▓рд┐рдпрд╛ рд╣реИ!

рдЕрдм рдЖрдк modern, responsive websites рдмрдирд╛ рд╕рдХрддреЗ рд╣реИрдВред Keep practicing рдФрд░ Week 3 рдореЗрдВ рдорд┐рд▓рддреЗ рд╣реИрдВ! ЁЯЪА