These HTML and CSS prompts help you generate responsive layouts and components, convert designs into code, fix layout bugs, refactor messy stylesheets and improve front-end performance and accessibility. They work with plain CSS, Tailwind, Bootstrap or any framework.
20 prompts on this page. Last updated: 4 December 2026. Written and tested by Saad Raza.
How to use these prompts
- Click Copy on any prompt.
- Paste it into ChatGPT, Claude, Gemini, Copilot or Perplexity.
- Replace everything in [square brackets] with your own details. The more specific you are, the better the answer.
- Read and edit the result before you use it. Add your own experience and check every fact, name and number.
Tell the AI your setup (plain CSS, Tailwind or a framework, and which browsers you support) so the code fits your project. Always test generated code in real browsers and on a phone.
Building
1. Build a responsive section
Write semantic HTML and CSS for a [section, e.g. hero with image and two buttons] that is mobile-first, uses CSS Grid or Flexbox, and has no external dependencies. Use CSS custom properties for colours: [colours].
2. Convert a design description into code
Convert this design into HTML and [CSS or Tailwind]: [describe layout, spacing, fonts, colours]. Make it responsive at [breakpoints] and accessible.
3. Build a navigation bar
Build an accessible responsive navigation bar with a logo, links, a call to action button and a mobile hamburger menu that works with keyboard and screen readers. Minimal JavaScript.
4. Build a pricing table
Build a responsive 3-column pricing table in HTML and CSS with a highlighted plan, feature list and buttons, stacking on mobile.
5. Build a contact form
Write an accessible contact form with labels, required fields, HTML5 validation, helpful error messages and a styled submit button.
6. Build an FAQ accordion
Build an accessible FAQ accordion using details and summary elements, styled with CSS, with smooth open and close.
7. Build a card grid
Build a responsive card grid that shows 1 column on mobile, 2 on tablet and 3 on desktop using CSS Grid with auto-fit and minmax.
8. Build a sticky header
Write CSS for a header that becomes sticky with a shadow after scrolling, without layout shift.
Fixing
9. Fix a layout bug
This layout breaks on [screen size or browser]: [paste HTML and CSS]. Explain why and give the fixed code.
10. Centre something
I want to centre [element] horizontally and vertically inside [container]. Here is my code: [paste]. Give the simplest modern CSS solution.
11. Fix horizontal scrolling on mobile
My page scrolls sideways on mobile. Here is the relevant code: [paste]. Find what overflows and fix it.
12. Fix CSS specificity problems
My styles are being overridden: [paste CSS and HTML]. Explain the specificity conflict and fix it without using !important.
Improving
13. Refactor CSS
Refactor this CSS to remove duplication, use custom properties and a consistent naming convention like BEM, without changing how it looks: [paste].
14. Convert CSS to Tailwind
Convert this HTML and CSS to Tailwind CSS classes: [paste].
15. Add dark mode
Add dark mode to this stylesheet using prefers-color-scheme and CSS custom properties: [paste].
16. Improve accessibility of markup
Review this HTML for accessibility: headings, landmarks, alt text, labels, buttons vs links, focus states and ARIA misuse. Return fixed code: [paste].
17. Improve front-end performance
Review this page's HTML head and assets: [paste]. Suggest improvements for loading CSS, fonts, images and scripts to improve Core Web Vitals.
18. Add animations
Add subtle CSS animations to [elements] that respect prefers-reduced-motion: [paste code].
19. Write responsive images
Write responsive image markup using srcset, sizes and lazy loading for this image at these widths: [details].
20. Explain this code
Explain what this HTML and CSS does, line by line, for a beginner: [paste].
What are HTML and CSS prompts?
HTML and CSS prompts help you generate responsive layouts and components, convert designs into code, fix layout bugs, refactor stylesheets, convert CSS to Tailwind, add dark mode and improve accessibility and performance. Tell the AI whether you use plain CSS, Tailwind or a framework so the code fits your project.
How to write better HTML and CSS prompts
- Ask for semantic HTML: it helps accessibility and SEO.
- Request mobile-first CSS: with Grid and Flexbox rather than fixed widths.
- Paste the real code: bugs are easier to fix in context.
- Test in real browsers: and on an actual phone.
Best AI tools to use with these prompts
Use ChatGPT, Claude or GitHub Copilot to write and fix code, Chrome or Firefox DevTools to debug layouts, CodePen to test snippets, and Lighthouse to check performance and accessibility.
Frequently asked questions
Can ChatGPT write HTML and CSS?
Yes. AI writes good HTML and CSS for common layouts and components. Test it in different browsers and screen sizes, and check accessibility.
Should I use Flexbox or Grid?
Use Flexbox for one-dimensional layouts, such as a row of buttons, and Grid for two-dimensional layouts, such as a card grid or page layout.
How do I make my site responsive?
Start with the mobile layout, use flexible units and modern layout tools, add breakpoints where the design needs them, and test on real devices.
Can ChatGPT write responsive CSS?
Yes. Ask for mobile-first CSS using Grid or Flexbox, with your breakpoints, and test the result on different screen sizes.
Should I use Tailwind or plain CSS?
Tailwind speeds up building with utility classes; plain CSS gives full control with no build step. Both work well, so choose what your team prefers.
More website design prompts
- UI Design PromptsLayouts, components, colour, type and visual hierarchy.
- UX Design and Research PromptsUser research, personas, journeys and usability tests.
- WordPress PromptsThemes, plugins, blocks, Elementor and site fixes.
- Web Accessibility PromptsWCAG checks, alt text, contrast and keyboard access.
- Website Redesign PromptsPlan, audit and launch a redesign without losing traffic.
Back to all website design prompts or the full prompt library, including SEO prompts.
Clean code helps your site load fast and rank better. Request a free audit and I will show you what to fix first.
Request received
Thank you! Saad will contact you within the next 24 hours.
Keep an eye on your phone and inbox.
