Front-End CSS & Tailwind Quick Notes
🧩 Front-End CSS & Tailwind Quick Notes for Interviews
🧑🤝🧑 Avatars
flex→ arranges avatars horizontally-space-x-1→ creates slight overlap between avatarsoverflow-hidden→ hides the overflow to keep edges cleanrelative + absolute→ parent sets position context; child (dot) fixed in a corneroutline→ simple line borderring→ shadow-based border with adjustable thickness (ring-2 ring-white)dark:prefix → applies dark mode styles (class="dark"or media query)
🧠 Key idea:
flex = layout, relative = positioning, dark: = theme switch
🏷️ Badges
inline-flex+items-center→ inline behavior + vertical centeringrounded-md→ rectangular with soft cornersrounded-full→ fully pill-shaped- “With border” → uses
ring-1 ring-insetfor subtle depth - “Flat” → no border, clean minimalist look
group-hover:→ enables hover effect sharing between parent & child- Status dot →
<span>+<svg>+ color class (fill-green-500)
🧠 Comparison notes:
border = depth / separation flat = clean / minimal rounded-full = pill shape inline-flex = inline + flex alignment
🔽 Dropdowns
<div>
<button>Menu <svg>▼</svg></button>
<div>
<a>Item</a>
<form><button>Sign out</button></form>
</div>
</div>
<a>→ navigation behavior<select>→ form selection behaviordivide-y→ adds separators- parent uses
relative, dropdown usesabsolute
🧠 Pattern:
Dropdown = relative parent + absolute panel
🔘 Buttons
<button class="inline-flex items-center gap-2 rounded-md bg-indigo-600 text-white">
<svg></svg> Button
</button>
- Primary → main action
- Secondary → neutral / outline action
- Soft → low-emphasis background
- Circular → icon-only button (
rounded-full)
🧠 Tip:
<button>is semantic and focusable. Don’t use<a>for button behavior.
🔔 Notifications & Alerts
Structure layers:
fixed inset-0 → screen container
flex-col → notification stack
white rounded box → single notification card
contains: icon + text + close button
| Type | Description |
|---|---|
| Alert | inline blocking message |
| Notification | floating non-blocking message |
🧠 Quick diff:
Alert = interruptive Notification = informative flex = layout, shadow = elevation
📍 Positioning
| Property | Meaning |
|---|---|
static | default, no movement |
relative | slightly moved but stays in flow |
absolute | removed from flow, relative to parent |
fixed | fixed to viewport |
sticky | scrolls until threshold, then sticks |
🧠 Mnemonic:
static (still), relative (slightly moved), absolute (floats), fixed (stays), sticky (half-fixed)
🧭 Navigation / Pagination
<nav>
<ul class="flex gap-2">
<li><a>1</a></li>
<li><a class="bg-accent/10 font-semibold">2</a></li>
</ul>
</nav>
flexdistributes page numbers horizontallybg-accent/10marks current page
🧠 Common question:
How to build pagination layout with flex and border utilities.
🪟 Modal Dialogs
<div class="fixed inset-0 flex items-center justify-center bg-black/30">
<div class="bg-white rounded-lg p-6 shadow-lg">
<h2>Title</h2>
<p>Content</p>
<div class="flex justify-end gap-2">
<button>Cancel</button>
<button>Confirm</button>
</div>
</div>
</div>
- Background layer →
fixed - Content box →
shadow + rounded - Buttons → aligned right via
justify-end
🧠 Tip:
Use
flexfor centering both vertically and horizontally.
🧱 Semantic HTML
| Tag | Meaning | Usage |
|---|---|---|
<dl> | definition list | key-value data |
<dt> | term | key / label |
<dd> | description | value |
<ul> | unordered list | container |
<li> | list item | individual entry |
🧠 Interview point:
Use semantic tags based on content type (list, table, or key-value).
📝 Forms & Inputs
| Category | Type | Example |
|---|---|---|
| Text | text, email, password | input fields |
| Selection | checkbox, radio, file | multi/single choice |
| Time | date, time, month | pickers |
| Hidden | hidden | token or ID field |
Attribute meanings:
| Attribute | Purpose |
|---|---|
id | connects to <label> |
name | form field name |
value | submitted value |
🧠 Common mistake:
Radios in the same group must share the same
nameto be mutually exclusive.
⚙️ Tailwind Core Interview Concepts
| Concept | Key Point |
|---|---|
flex vs inline-flex | block-level vs inline-level container |
relative + absolute | child positions relative to parent |
outline vs ring | flat line vs layered shadow |
dark: mode | toggled by .dark class or media query |
rounded-md vs rounded-full | soft rectangle vs pill shape |
border vs flat | depth vs minimalism |
group-hover | hover state sharing |
flex-1 | evenly distribute space |
responsive grid | 1 col → 2 col → 3 col layout |
💡 Recap (for quick review)
- Flex arranges, Relative positions, Ring adds depth.
- Inline-flex for inline alignment, Rounded-full = pill shape.
- Dark: toggles theme, Group-hover shares hover states.
- Alert blocks, Notification floats.
<dl>= key-value pair,<ul>= list.- Radios share name, Checkboxes don’t.