Deck 13 - HTML/CSS/Responsive/DOM Basics (Reviewer Essentials) (objective)
Goal: review UI code like a senior: semantic HTML, forms, layout, responsive patterns, DOM/events, and common browser pitfalls.
You learn: what/why (under the hood), common mistakes, and review-grade wording.
Output style: PASS/PARTIAL/FAIL + 2-3 issues + fix approach.
Semantics: why choose <button> vs <div onClick>?</button>
button has built-in keyboard support, focus management, and correct ARIA role.
div onClick requires manual keyboard handlers, tabindex, and ARIA; often fails accessibility and behavior parity.
Semantics: link vs button rule.
Use <a> for navigation (changes URL / goes to another resource).
Use <button> for actions (mutations, toggles, submitting forms).</button></a>
Forms: why button type matters.
Inside a form, <button> defaults to type=’submit’.
Best practice: set type=’button’ for non-submit buttons to avoid accidental submissions.</button>
Forms: label association (best practice).
Every input needs an accessible name: <label> or wrapping label, or aria-label/aria-labelledby.
Why: screen readers and click targets; also improves usability.</label>
Forms: placeholder is not a label (why).
Placeholder disappears on input and is not a reliable accessible name.
It also has low contrast by default; use a proper label.
Forms: controlled vs uncontrolled basics.
Controlled inputs rerender on each change; easier validation.
Uncontrolled use defaultValue/ref and read on submit; can be faster for huge forms.
Forms: autocomplete best practice.
Use autocomplete hints like email, name, current-password.
Why: improves UX and reduces errors; helps password managers.
HTML: headings hierarchy rule.
Use a logical heading order (h1 then h2, etc.)
Why: screen reader navigation, SEO, and structure.
HTML: list semantics rule.
Use <ul>/<ol> for lists; not a series of <div> elements.
Why: semantics, accessibility, and consistent spacing behavior.
Images: alt text rule.
Decorative images: alt=’’. Informative images: meaningful alt.
Why: screen readers; missing alt can be noisy or unhelpful.
Images: width/height attributes (why).
Providing intrinsic dimensions reduces layout shift.
Why: avoids CLS-like jank as images load.
CSS: box model basics (under the hood).
Elements have content + padding + border + margin.
box-sizing: border-box makes width/height include padding/border, reducing layout surprises.
CSS: specificity basics.
More specific selectors win; !important overrides most.
Best practice: avoid deep specificity wars; use consistent class-based styling.
Layout: flex vs grid rule of thumb.
Flex: 1D layout (row OR column). Grid: 2D layout (rows and columns).
Pick based on whether you need alignment in both axes.
Responsive: mobile-first principle.
Start with base styles for small screens, then add min-width breakpoints.
Why: fewer overrides; better defaults for narrow devices.
Responsive: common breakpoints (practical).
No single standard, but common: 480, 768, 1024, 1280.
Best practice: use content-based breakpoints rather than device-based.
Responsive: avoid fixed widths (rule).
Prefer max-width, flex, grid, and fluid units.
Why: fixed widths break on small screens and cause overflow.
Units: rem/em/vw/vh (quick).
rem: root font size; em: relative to parent; vw/vh: viewport.
Best practice: use rem for typography and spacing; use vw/vh carefully (mobile address bar quirks).
Overflow: why text truncation needs more than one rule.
Truncation requires overflow hidden + text-overflow ellipsis + white-space nowrap (single line).
For multi-line, use line-clamp patterns with fallbacks.
DOM: event bubbling vs capturing (why you care).
Events bubble from target up; capturing goes down.
Why: delegation and unexpected parent handlers firing; stopPropagation is sometimes needed (sparingly).
DOM: default actions (example).
Links navigate; forms submit; space/enter activate buttons.
If you preventDefault, ensure you still provide expected behavior.
DOM: focus management basics.
Focusable elements (button, input, link) participate in tab order.
Avoid tabindex>0; use tabindex=0 only when you must make custom elements focusable.
DOM: why :focus-visible is preferred.
Shows focus ring for keyboard users without always showing it for mouse clicks.
Best practice: do not remove focus outlines; style them intentionally.
```