CSS stands for Cascading Style Sheets.
CSS is used to design and style websites. It controls colors, layouts, spacing, fonts, responsiveness, animations, and the overall look of a webpage.
HTML creates the structure of a webpage, while CSS makes it visually attractive.
CSS can be added in 3 different ways.
CSS is written directly inside an HTML tag.
[code theme="dark"]Hello CSS
[/code]Use Case: Quick styling for a single element.
CSS is written inside the <style> tag.
[code theme="dark"] [/code]Use Case: Styling a single page.
CSS is written in a separate .css file and linked with HTML.
[code theme="dark"] [/code]style.css
[code theme="dark"] p{ color: green; } [/code]Use Case: Professional and reusable styling.
Email templates mostly use Inline CSS.
Many email clients do not fully support external stylesheets or advanced CSS features.
[code theme="dark"]| Welcome User |
Block elements take the full width available.
Examples: div, p, h1
Inline elements only take the width of their content.
Examples: span, a
Works like inline elements but also allows width and height.
A one-dimensional layout system used for alignment and spacing.
A two-dimensional layout system for rows and columns.
Example:
[code theme="dark"] h1{ color: red; font-size: 40px; } [/code]Padding creates space inside an element.
[code theme="dark"] .box{ padding:20px; } [/code]Margin creates space outside an element.
[code theme="dark"] .box{ margin:20px; } [/code]Shorthand properties allow multiple values in a single line.
[code theme="dark"] padding: 10px 20px 30px 40px; [/code]Variables help create reusable values.
[code theme="dark"] :root{ --main-color: #ff6600; } button{ background: var(--main-color); } [/code]Flexbox is mainly used for alignment and spacing.
[code theme="dark"] .container{ display:flex; justify-content:center; align-items:center; gap:20px; } .box{ width:100px; height:100px; background:red; } [/code]CSS Grid is used for advanced layouts.
[code theme="dark"] .container{ display:grid; grid-template-columns: repeat(3, 1fr); gap:20px; } .box{ background:#ddd; padding:20px; } [/code]Responsive design means a website automatically adjusts for different screen sizes.
[code theme="dark"] @media(max-width:768px){ .container{ flex-direction:column; } } [/code]Media Queries are used to create responsive layouts.
Earlier developers used to write all CSS manually.
Now many frameworks are available:
However, real projects often require custom CSS based on project requirements.
That is why understanding core CSS concepts is still very important.
SCSS is a CSS preprocessor.
Developers write code in SCSS, and it finally gets compiled into normal CSS.
Nesting creates a cleaner and more readable structure.
Mixins help create reusable styles.
[code theme="dark"] @mixin flex-center{ display:flex; justify-content:center; align-items:center; } .box{ @include flex-center; } [/code]SCSS files can be separated by components.
| CSS | SCSS |
|---|---|
| Simple styling | Advanced styling |
| No nesting | Nesting support |
| No mixins | Mixin support |
| Direct browser support | Needs compilation |
CSS is the design system of a website.
Modern frameworks like Bootstrap and Tailwind make development faster, but real-world projects still require custom CSS.
That is why understanding concepts like:
is extremely important for every frontend developer.
SCSS improves development by providing features like nesting, variables, mixins, and reusable structures.
In simple words:
HTML creates the structure, and CSS makes it beautiful.