CSS Kya Hai?
CSS (Cascading Style Sheets) HTML elements ki STYLING control karta hai — colors, fonts, spacing, layout, animations, sab kuch. HTML "kya hai" batata hai, CSS "kaisa dikhta hai" decide karta hai.
CSS rules ek simple pattern follow karte hain: selector { property: value; } — selector batata hai KAUNSA element target karna hai, property-value pair batata hai WHAT style apply karni hai.
CSS ko HTML se connect karne ke 3 tareeke hain: external stylesheet (<link rel="stylesheet">, sabse common aur best practice), internal (<style> tag <head> mein), inline (style="..." attribute directly element par, avoid karo generally).
/* style.css */
h1 {
color: blue;
font-size: 32px;
}
p {
color: gray;
line-height: 1.6;
}- CSS = styling/presentation layer, HTML = structure
- selector { property: value; } = basic rule syntax
- External stylesheet (<link>) = best practice, inline avoid karo
CSS3 (jo aaj "CSS" ka current standard mana jaata hai) modules mein evolve hota hai (Selectors, Flexbox, Grid, Animations alag-alag specs hain) — isliye "CSS4" jaisa koi single version nahi hai, features individually browsers mein add hote rehte hain.
/* Modern browsers naye features support karte hain: */
.modern {
display: grid; /* CSS Grid (relatively recent) */
gap: 20px; /* Modern spacing property */
aspect-ratio: 16 / 9; /* Very modern feature */
}Different browsers ka default styling thoda alag hota hai (margins, font sizes) — "CSS reset" (sab kuch zero kar dena) ya "normalize.css" (consistent, sensible defaults) se cross-browser consistency achieve karte hain, project shuru karte waqt.
/* Simple reset example: */
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}