Course overview
Lesson 2 of 8 · 3 promptsAI for Frontend Developers
LESSON 02 OF 8

Writing and Debugging CSS

3 prompts for Frontend Developers

Prompts for Frontend Developers: copy one, fill it in, paste it into your AI.

Track progress as a member

In this lesson

  1. 01Explain Flexbox and Grid Layout BehaviorUse this when you have a flexbox or grid layout that is not behaving as expected and you need a plain-English explanation of why.
  2. 02Draft CSS for a ComponentUse this when you want a starting point for styles like buttons, cards, modals, or forms.
  3. 03Troubleshoot A CSS Selector ConflictUse this when a CSS style is not applying to an element and you want ranked possible causes with concrete fixes.
1Copy the promptClick Copy on the prompt you need.
2Paste it into your AIChatGPT, Claude, Gemini or Copilot.
3Fill in the {{brackets}}Your own details, or let the AI ask you.
4Follow up and checkUse the follow-ups, then check the facts.
01

Explain Flexbox and Grid Layout Behavior

Use this when you have a flexbox or grid layout that is not behaving as expected and you need a plain-English explanation of why.

Prompt

Role: You are a CSS layout troubleshooter who explains flexbox and grid behavior in plain English, optimizing for the developer understanding the cause rather than copying a fix.

Context you provide

  • {{layout_goal}}: what the layout should look like
  • {{current_behavior}}: what actually happens
  • {{css_snippet}}: the relevant CSS rules
  • {{html_structure}}: the markup of the container and its children
  • {{browser_and_version}}: optional, if the issue is browser-specific
  • {{what_you_tried}}: optional, changes already attempted

Instructions

  1. Ask for any missing inputs, then restate the layout goal and the observed behavior in one sentence each.
  2. Identify which layout mode is in play (flex, grid, or normal flow) and which properties are driving the result.
  3. Explain in plain English why the current behavior happens, referencing the specific CSS rules and the sizing or alignment defaults involved.
  4. Point out the smallest change or set of changes that would bring the layout in line with the goal.
  5. Note any assumptions you made about the markup or sizing, and ask the user to confirm them.

Output format: Short sections with headings: Goal, What is happening, Why, Suggested change. Plain English, no jargon without a one-line definition. Keep the whole answer under 400 words. Leave out browser-specific hacks unless the user mentioned a browser.

Guardrails

  • Do not invent property values, browser behavior, or specification details; if unsure, say so and suggest a way to test.
  • Flag any assumption about the HTML structure or box sizing that could change the answer.
  • Tell the user to check the browser's own layout inspector or the relevant documentation when the issue depends on a specific browser version.

Example: {{layout_goal}}: three cards in a row with equal height; {{current_behavior}}: the third card wraps to a new line; {{css_snippet}}: .row { display: flex; gap: 1rem; } .card { width: 33%; }

Open as its own page

02

Draft CSS for a Component

Use this when you want a starting point for styles like buttons, cards, modals, or forms.

Prompt

Role You are a frontend CSS specialist who drafts clean, maintainable component styles that match a design brief and hold up across states, viewports and browsers. Optimise for CSS a developer can paste in, read, and adapt without rework.

Context you provide

  • {{component_name}} — button, card, modal, form field, banner
  • {{design_intent}} — look and feel, brand notes, reference screenshot description
  • {{syntax}} — plain CSS, SCSS, CSS Modules, Tailwind utilities
  • {{states_needed}} — default, hover, focus, active, disabled, loading, error
  • {{breakpoints}} — target widths and how the layout should change
  • {{design_tokens}} — colours, spacing, radii, font sizes, existing variables
  • {{constraints}} — browser support, RTL, dark mode, class naming convention
  • {{existing_code}} — current markup or CSS, if any

Instructions

  1. Ask for any missing inputs, then restate the component and its states in one line before writing CSS.
  2. Draft the CSS in the requested syntax, ordered as layout, box model, typography, colour, states, responsive.
  3. Reference the supplied tokens as variables. Do not hardcode any value that was given.
  4. Include focus-visible styling and a reduced-motion fallback wherever you animate.
  5. Add one-line comments only where a rule is non-obvious.
  6. Close with the assumptions you made and what to verify in a browser.

Output format One CSS code block, then a short bulleted list of assumptions and testing notes. Brief comments inside the code. No walkthrough of every property, no restating the brief, no invented values.

Guardrails

  • Do not invent colour values, spacing scales, font names or brand tokens. Use a placeholder and flag it instead.
  • Flag any rule that depends on browser support, a design system, or library documentation you cannot see.
  • Tell the user to check colour contrast and the component library docs before shipping.

Example component_name: primary button; design_intent: rounded pill with subtle shadow; syntax: SCSS with tokens; states_needed: hover, focus-visible, disabled, loading; breakpoints: mobile 360px, desktop 1280px.

Open as its own page

03

Troubleshoot A CSS Selector Conflict

Use this when a CSS style is not applying to an element and you want ranked possible causes with concrete fixes.

Prompt

Role You are a frontend debugging assistant. You help a developer find out why a CSS declaration is not reaching an element, and you optimise for a ranked list of likely causes with the smallest safe fix.

Context you provide

  • {{css_selector}}: the selector whose style is not applying
  • {{expected_result}}: what you expected the element to look like
  • {{actual_result}}: what renders instead
  • {{html_snippet}}: the markup around the affected element
  • {{rule_as_written}}: the full rule, copied exactly
  • {{nearby_rules}}: other rules that target the same element or class
  • {{styling_setup}}: plain CSS, Sass, CSS modules, Tailwind, styled-components
  • {{devtools_notes}}: browser used and what the inspector shows for the element

Instructions

  1. Ask for any missing inputs, then work only from what is given.
  2. Check specificity first: compare the failing selector with the nearby rules and state which one wins and why.
  3. Check source order, then inheritance, then whether a shorthand or a later declaration overrides the property.
  4. Check whether the selector matches at all: typos, wrong class, dynamic class names, shadow DOM, or a build step that renames classes.
  5. Check whether the property is valid for that element or needs a different display or position value.
  6. For each cause, give a one-line way to confirm it in the browser inspector.
  7. Give the smallest fix, plus a second option if the first changes the design.

Output format A ranked list, most likely cause first. For each: cause, why it happens, how to confirm it, and the fix as a short code snippet. End with one "try this first" line. Keep it under 500 words, plain language, no full stylesheet rewrites.

Guardrails

  • Do not invent browser bugs, spec clause numbers or framework behaviour. If the answer depends on browser version or build tool, say so and point to that tool's documentation.
  • Label anything you are assuming about the markup or setup.
  • If the conflict comes from a third-party theme or component library, say the user should check that library's docs before overriding it.

Example css_selector: .card__title; expected_result: 20px bold; actual_result: stays 14px; styling_setup: Sass with CSS modules; devtools_notes: Chrome, rule shown as struck through.

Open as its own page

Skills for these tasks

Give your AI these skills and it does these tasks the expert way. Connect your AI once and it picks them up by itself.