GPT 5 Available DeepSeek V4 Available Kimi K2.6 Available GPT 5 Mini Available DeepSeek V3.2 Available GPT 5.4 Available GPT 5.4 mini Available Grok 4 Available Llama 3.1 Available Phi 4 Available GLM 5.2 by Z.ai Available Claude Haiku 5.5 Available
Free AI chat models, no sign upSee all chat models →
Buy me a coffee
GPT 5 Available DeepSeek V4 Available Kimi K2.6 Available GPT 5 Mini Available DeepSeek V3.2 Available GPT 5.4 Available GPT 5.4 mini Available Grok 4 Available Llama 3.1 Available Phi 4 Available GLM 5.2 by Z.ai Available Claude Haiku 5.5 Available
Free AI chat models, no sign upSee all chat models →
Free AI CSS Generator

Generate CSS Code Instantly

Create clean CSS code for layouts, animations and responsive designs for free with AIFreeForever's AI CSS Generator. Each stylesheet comes with clear class names and the HTML it expects in a comment.

Pick the CSS technique and browser support to generate your CSSPick the technique and browsers
CSS Technique
Browser Support
Describe your styles
Quick CSS techniques you can choose from

What is CSS Generator

Centered hero graphic for an Ai Css Generator showing a polished UI panel with a CSS class input, minimalist dropdown, layout toggle, and Generate button over a designer workspace with code visuals and subtle grid lines.

This tool generates clean, modern CSS code for layouts, animations, responsive design, and visual effects. Get browser-compatible CSS with proper vendor prefixes and fallbacks.

AI CSS GeneratorMade by AIFreeForever
Generate my CSS free
DetailInformation
ToolAI CSS Generator by AIFreeForever
InputDescribe the styling in the chat box
TechniquesModern CSS, Flexbox, CSS Grid and more
Browser supportModern Browsers, IE11+ or All Browsers with fallbacks
OutputA stylesheet with clear class names and the expected HTML in a comment, as styles.css
PricingFree

Why Use the AI CSS Generator?

Styling a layout takes time. The AI CSS Generator writes the stylesheet with the technique and browser support you pick. It runs on several AI models you can switch between and compare, such as Claude Haiku 5.5, GPT-6 Luna and more.

  • AIFreeForever's AI CSS Generator is free to use.
  • No login, no sign up for your first few messages.
  • After that, you may be asked to verify your email with a one-time code.
AI CSS generator benefits from the free CSS Generator: a web designer arranging a colourful page layout at a bright desk

How to Use CSS Generator

Follow these simple steps to use the ai css generator:

  1. 1

    Describe in the chat box what the CSS should style and how it should look. For example, ask for a centered card with a shadow and a hover effect.

  2. 2

    Pick Modern CSS, Flexbox or CSS Grid under CSS Technique on the settings card. You can also choose Animations, Responsive Design or Transitions.

  3. 3

    Choose Modern Browsers, IE11+ or All Browsers with fallbacks under Browser Support, for the browsers the site must work in.

  4. 4

    Press Generate CSS to get the stylesheet as coloured code with clear class names.

  5. 5

    Copy the CSS or download styles.css, use the HTML from the comment at the end, then check it in the browsers the site needs.

The CSS Layout Cheat Sheet, 2026 Free PDF with:
  • A guide on when to use Flexbox or Grid
  • A request template for the AI CSS Generator
  • A checklist to test CSS before it goes live
Download free PDF

CSS Techniques the AI CSS Generator Uses

AIFreeForever's AI CSS Generator writes your stylesheet with the technique you pick, and each technique is written its own way.

Modern CSS

The stylesheet uses custom properties, clamp() and modern selectors such as :is() and :focus-visible. This suits a clean site header or card layout that stays easy to update.

CSS Browser Support and Fallbacks Explained

AIFreeForever's AI CSS Generator lets you pick how far back your stylesheet must work, from current browsers to every browser with fallbacks.

Modern Browsers

The CSS uses standard properties and only the vendor prefixes current Chrome, Edge, Firefox and Safari still need. Pick this level for a new site aimed at people on up-to-date devices.

Who Can Use an AI CSS Generator?

The six groups below all need clean CSS quickly, and AIFreeForever's AI CSS Generator writes a stylesheet from a short description.

  • For Web Designers

    Designers describe a card grid or hero section and receive class names such as .card, ready to paste into a client project.

  • For Front-End Developers

    Developers pick CSS Grid or Modern CSS and get custom properties, clamp() sizing and :focus-visible styles they can extend.

  • For Students Learning CSS

    Students generate the same layout with Flexbox and Grid, then read the comments above each rule group to see how each technique works.

  • For Bloggers and Small Business Owners

    Owners describe a simple page and receive a stylesheet with readable text, rem sizing and the expected HTML in a closing comment.

  • For WordPress Theme Builders

    Theme builders request IE11+ support and get fallback values before each variable, so older browsers still show a working layout.

  • For Email and Landing Page Marketers

    Marketers ask for hover effects and responsive media queries. Then they copy the result into a landing page and test it in the browsers their campaign needs.

Examples of Content Generated by CSS Generator

The six examples are real stylesheets made by AIFreeForever's AI CSS Generator, each shown working beside its code. They help web designers and students who want a starting point they can read and change. Pressing Generate CSS like this loads the example's description, technique and browser support into the settings card.

Here are some examples of what you can create with our tool: Explore our AI Responsive Generator for more specialized results.

Responsive navbar with mobile menu

A responsive navbar with a logo on the left and links that stack into a mobile menu on small screens

Responsive Design · Modern Browsers · 165 lines
/* Responsive navbar: logo left, links stack into a mobile menu on small screens */

/* Variables */
:root {
  --nav-bg: #ffffff;
  --nav-text: #1f2933;
  --nav-text-muted: #52606d;
  --nav-accent: #1d4ed8;
  --nav-border: #e4e7eb;
  --nav-focus: #1d4ed8;
}

/* Layout */
.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--nav-bg);
  border-bottom: 1px solid var(--nav-border);
}

.navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  max-width: 72rem;
  margin: 0 auto;
  padding: 0.75rem 1rem;
}

/* Logo */
.navbar__logo {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: clamp(1.125rem, 1rem + 0.5vw, 1.375rem);
  font-weight: 700;
  color: var(--nav-text);
  text-decoration: none;
}

.navbar__logo:hover {
  color: var(--nav-accent);
}

/* Hamburger toggle (checkbox, no JavaScript) */
.navbar__toggle {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

.navbar__toggle-label {
  display: inline-flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.3rem;
  width: 2.75rem;
  height: 2.75rem;
  padding: 0.6rem;
  border: 1px solid var(--nav-border);
  border-radius: 0.375rem;
  cursor: pointer;
}

.navbar__toggle-label span {
  display: block;
  height: 2px;
  background: var(--nav-text);
  border-radius: 1px;
}

/* Mobile menu: stacked links, hidden until toggled */
.navbar__links {
  display: none;
  width: 100%;
  flex-direction: column;
  padding: 0.5rem 0 0.75rem;
  border-top: 1px solid var(--nav-border);
}

.navbar__toggle:checked ~ .navbar__links {
  display: flex;
}

.navbar__link {
  display: block;
  padding: 0.75rem 0.25rem;
  font-size: 1rem;
  color: var(--nav-text-muted);
  text-decoration: none;
  border-radius: 0.25rem;
}

.navbar__link:hover {
  color: var(--nav-accent);
}

.navbar__link--active {
  color: var(--nav-accent);
  font-weight: 600;
}

/* States: visible keyboard focus for links and the toggle label */
.navbar__link:focus-visible,
.navbar__logo:focus-visible,
.navbar__toggle-label:focus-visible {
  outline: 2px solid var(--nav-focus);
  outline-offset: 2px;
}

.navbar__toggle:focus-visible + .navbar__toggle-label {
  outline: 2px solid var(--nav-focus);
  outline-offset: 2px;
}

/* Tablet and up: links in a row, hamburger hidden */
@media (min-width: 768px) {
  .navbar__toggle-label {
    display: none;
  }

  .navbar__links {
    display: flex;
    width: auto;
    flex-direction: row;
    align-items: center;
    gap: 0.5rem;
    padding: 0;
    border-top: none;
  }

  .navbar__link {
    padding: 0.5rem 0.75rem;
  }
}

/* Desktop: a little more breathing room */
@media (min-width: 1024px) {
  .navbar {
    padding: 0.875rem 2rem;
  }

  .navbar__links {
    gap: 1rem;
  }
}

/* Expected HTML:
<header class="site-header">
  <nav class="navbar">
    <a class="navbar__logo" href="/">My Site</a>
    <input type="checkbox" id="nav-toggle" class="navbar__toggle">
    <label for="nav-toggle" class="navbar__toggle-label" aria-label="Menu">
      <span></span><span></span><span></span>
    </label>
    <ul class="navbar__links">
      <li><a class="navbar__link navbar__link--active" href="/">Home</a></li>
      <li><a class="navbar__link" href="/about">About</a></li>
      <li><a class="navbar__link" href="/contact">Contact</a></li>
    </ul>
  </nav>
</header> */

CSS Grid gallery layout

A photo gallery grid with captions that fits as many columns as the screen allows

CSS Grid · Modern Browsers · 141 lines
/* Photo gallery grid with captions — responsive CSS Grid for current Chrome, Edge, Firefox and Safari */

/* Variables */
:root {
  --page-bg: #f4f2ee;
  --card-bg: #ffffff;
  --ink: #26241f;
  --ink-soft: #5d5a52;
  --accent: #0b57d0;
  --radius: 0.6rem;
  --shadow: 0 0.125rem 0.5rem rgb(38 36 31 / 0.12);
  --shadow-lift: 0 0.375rem 1rem rgb(38 36 31 / 0.2);
}

/* Page layout */
.page {
  max-width: 75rem;
  margin: 0 auto;
  padding: 2rem 1rem 3rem;
  background-color: var(--page-bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  line-height: 1.5;
}

.page__title {
  margin: 0 0 1.5rem;
  font-size: 1.75rem;
  letter-spacing: -0.01em;
}

/* Gallery grid: auto-fit packs in as many columns as the screen allows */
.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
  gap: 1rem;
  margin: 0;
  padding: 0;
}

/* Card parts */
.gallery__item {
  margin: 0;
  overflow: hidden;
  background-color: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.gallery__link {
  display: block;
  color: inherit;
  text-decoration: none;
}

.gallery__image {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.gallery__caption {
  display: block;
  padding: 0.75rem 1rem 1rem;
}

.gallery__title {
  display: block;
  font-size: 1rem;
  font-weight: 600;
  color: var(--ink);
}

.gallery__meta {
  display: block;
  margin-top: 0.25rem;
  font-size: 0.85rem;
  color: var(--ink-soft);
}

/* States */
.gallery__item:hover {
  box-shadow: var(--shadow-lift);
  transform: translateY(-0.125rem);
}

.gallery__link:hover .gallery__image {
  transform: scale(1.04);
}

.gallery__link:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: -3px;
}

/* Media queries */
@media (min-width: 48rem) {
  .page {
    padding: 3rem 2rem 4rem;
  }

  .page__title {
    font-size: 2.25rem;
  }

  .gallery {
    gap: 1.5rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .gallery__item,
  .gallery__link:hover .gallery__image {
    transition: none;
    transform: none;
  }
}

/*
HTML this stylesheet expects:

<section class="page">
  <h1 class="page__title">Travel photos</h1>
  <div class="gallery">
    <figure class="gallery__item">
      <a class="gallery__link" href="photo-1.html">
        <img class="gallery__image" src="photo-1.jpg" alt="Sailboats at sunset" width="800" height="600">
      </a>
      <figcaption class="gallery__caption">
        <span class="gallery__title">Sailboats at sunset</span>
        <span class="gallery__meta">August 2024 · Bay of Kotor</span>
      </figcaption>
    </figure>
    <!-- repeat the figure above for each photo -->
  </div>
</section>
*/

Smooth scroll animations

Smooth fade-in and slide-up animations for page sections, each one starting a little after the last

Animations · Modern Browsers · 138 lines
/* Staggered fade-in and slide-up animations for page sections */

/* Variables */
:root {
  --color-bg: #f6f7fb;
  --color-surface: #ffffff;
  --color-text: #1f2430;
  --color-muted: #4b5563;
  --color-accent: #1d4ed8;
  --color-accent-strong: #1e40af;
  --radius: 0.75rem;
  --shadow: 0 12px 30px rgba(31, 36, 48, 0.1);
  --rise-duration: 0.7s;
  --rise-easing: cubic-bezier(0.22, 1, 0.36, 1);
  --stagger-step: 0.15s;
}

/* Layout: page shell and the stack that holds the sections */
.page {
  min-height: 100vh;
  padding: 3rem 1.5rem;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  line-height: 1.6;
}

.section-stack {
  display: grid;
  gap: 2.5rem;
  max-width: 50rem;
  margin: 0 auto;
}

/* The parts: each section rises once, a step later than the last */
.page-section {
  opacity: 0;
  padding: 2rem;
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  animation: section-rise var(--rise-duration) var(--rise-easing) both;
}

.section-stack .page-section:nth-child(1) { animation-delay: 0s; }
.section-stack .page-section:nth-child(2) { animation-delay: var(--stagger-step); }
.section-stack .page-section:nth-child(3) { animation-delay: calc(var(--stagger-step) * 2); }
.section-stack .page-section:nth-child(4) { animation-delay: calc(var(--stagger-step) * 3); }
.section-stack .page-section:nth-child(5) { animation-delay: calc(var(--stagger-step) * 4); }
.section-stack .page-section:nth-child(6) { animation-delay: calc(var(--stagger-step) * 5); }

.page-section__title {
  margin: 0 0 0.75rem;
  font-size: 1.5rem;
  line-height: 1.25;
}

.page-section__text {
  margin: 0;
  font-size: 1rem;
  color: var(--color-muted);
}

/* Keyframes: opacity and transform only, so the motion stays smooth */
@keyframes section-rise {
  from {
    opacity: 0;
    transform: translateY(2rem);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* States: links, buttons and a visible keyboard focus ring */
.page-section a {
  color: var(--color-accent);
}

.page-section a:hover {
  color: var(--color-accent-strong);
}

.button {
  display: inline-block;
  margin-top: 1.25rem;
  padding: 0.6rem 1.4rem;
  font-size: 1rem;
  color: #ffffff;
  background: var(--color-accent);
  border: 0;
  border-radius: var(--radius);
  text-decoration: none;
  cursor: pointer;
}

.button:hover {
  background: var(--color-accent-strong);
}

.page-section a:focus-visible,
.button:focus-visible {
  outline: 3px solid var(--color-accent-strong);
  outline-offset: 2px;
}

/* Media queries */
@media (prefers-reduced-motion: reduce) {
  .page-section {
    animation: none;
    opacity: 1;
    transform: none;
  }
}

@media (max-width: 40em) {
  .page {
    padding: 2rem 1rem;
  }

  .page-section {
    padding: 1.5rem;
  }
}

/* HTML expected (paste this and the sections animate on load):
<body class="page">
  <main class="section-stack">
    <section class="page-section">
      <h2 class="page-section__title">Section title</h2>
      <p class="page-section__text">Section text with a <a href="#next">link</a>.</p>
      <a class="button" href="#next">Call to action</a>
    </section>
    <section class="page-section">…repeat for each following section…</section>
  </main>
</body>
*/

Card component with hover effects

A product card with an image, a title and a price that lifts up with a soft shadow on hover

Transitions · Modern Browsers · 97 lines
/* Product card: image, title and price with a soft lift on hover */

/* Variables */
:root {
  --card-bg: #ffffff;
  --card-border: #e3e6ea;
  --card-radius: 0.75rem;
  --ink: #1f2430;
  --ink-soft: #5a6270;
  --focus-ring: #0b5fd0;
  --shadow-rest: 0 1px 3px rgba(20, 24, 34, 0.08);
  --shadow-lift: 0 12px 28px rgba(20, 24, 34, 0.18);
  --lift: -0.375rem;
  --speed: 180ms;
  --ease: cubic-bezier(0.2, 0.6, 0.3, 1);
}

/* Layout */
.product-card {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 20rem;
  background-color: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--card-radius);
  overflow: hidden;
  box-shadow: var(--shadow-rest);
  text-decoration: none;
  color: inherit;
  transition: transform var(--speed) var(--ease), box-shadow var(--speed) var(--ease);
}

/* Parts */
.product-card__media {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  background-color: var(--card-border);
}

.product-card__body {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 1rem 1.25rem 1.25rem;
}

.product-card__title {
  margin: 0;
  font-size: 1.125rem;
  line-height: 1.3;
  font-weight: 600;
  color: var(--ink);
}

.product-card__price {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  color: var(--ink-soft);
}

/* States */
.product-card:hover,
.product-card:focus-visible {
  transform: translateY(var(--lift));
  box-shadow: var(--shadow-lift);
}

.product-card:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 3px;
}

/* Media queries */
@media (prefers-reduced-motion: reduce) {
  .product-card {
    transition: none;
  }

  .product-card:hover,
  .product-card:focus-visible {
    transform: none;
  }
}

/* Expected HTML:
<a class="product-card" href="#product">
  <img class="product-card__media" src="photo.jpg" alt="Trail running shoe" width="640" height="480">
  <div class="product-card__body">
    <h2 class="product-card__title">Trail Runner XT</h2>
    <p class="product-card__price">$129.00</p>
  </div>
</a>
*/

Styled HTML tables with striped rows, borders, and hover effects

Try the dedicated CSS table styler for instant table CSS with a live preview.

A data table with striped rows, thin borders and a highlighted row on hover

Modern CSS · All Browsers (with fallbacks) · 133 lines
/* Styles for a data table: striped rows, thin borders and a highlighted row on hover */

/* --- Variables: colours, spacing, radius --- */
:root {
  --dt-bg: #ffffff;
  --dt-bg-stripe: #f5f7fa;
  --dt-bg-hover: #e9f0fb;
  --dt-head-bg: #e9edf3;
  --dt-border: #d5dbe3;
  --dt-ink: #1f2933;
  --dt-accent: #1b4fa0;
  --dt-space: 0.75rem;
  --dt-radius: 0.5rem;
}

/* --- Layout: scroll wrapper keeps wide tables usable on small screens --- */
.data-table__wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  background-color: #ffffff;
  background-color: var(--dt-bg);
  border: 1px solid #d5dbe3;
  border: 1px solid var(--dt-border);
  border-radius: 8px;
  border-radius: var(--dt-radius);
}

/* --- Parts: table, caption, cells, header row, numeric cells, links --- */
.data-table {
  width: 100%;
  border-collapse: collapse;
  border-spacing: 0;
  line-height: 1.5;
  color: #1f2933;
  color: var(--dt-ink);
  font-size: 1rem;
  font-size: clamp(0.9375rem, 0.9rem + 0.25vw, 1.0625rem);
}

.data-table__caption {
  text-align: left;
  font-weight: 700;
  font-size: 1rem;
  font-size: clamp(1rem, 0.9rem + 0.5vw, 1.125rem);
}

.data-table th,
.data-table td {
  text-align: left;
  vertical-align: top;
  padding: 0.5rem 0.75rem;
  padding: calc(var(--dt-space) / 2) var(--dt-space);
  border-bottom: 1px solid #d5dbe3;
  border-bottom: 1px solid var(--dt-border);
}

.data-table thead th {
  background-color: #e9edf3;
  background-color: var(--dt-head-bg);
}

.data-table__num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.data-table__link {
  color: #1b4fa0;
  color: var(--dt-accent);
  text-decoration: underline;
}

/* --- States: stripes, hover and keyboard highlight, focus ring --- */
.data-table tbody tr:nth-child(even) {
  background-color: #f5f7fa;
  background-color: var(--dt-bg-stripe);
}

.data-table tbody tr:hover {
  background-color: #e9f0fb;
  background-color: var(--dt-bg-hover);
}

@supports (selector(:focus-within)) {
  .data-table tbody tr:focus-within {
    background-color: #e9f0fb;
    background-color: var(--dt-bg-hover);
  }
}

.data-table__link:focus {
  outline: 2px solid #1b4fa0;
  outline: 2px solid var(--dt-accent);
  outline-offset: 2px;
}

@supports (selector(:focus-visible)) {
  .data-table__link:focus:not(:focus-visible) {
    outline: none;
  }

  .data-table__link:focus-visible {
    outline: 2px solid #1b4fa0;
    outline: 2px solid var(--dt-accent);
    outline-offset: 2px;
  }
}

/* --- Media queries: tighter cells on small screens --- */
@media (max-width: 40em) {
  .data-table th,
  .data-table td {
    padding: 0.375rem 0.5rem;
    padding: calc(var(--dt-space) / 2) calc(var(--dt-space) / 1.5);
  }
}

/* --- Expected markup ---
<div class="data-table__wrap">
  <table class="data-table">
    <caption class="data-table__caption">Monthly revenue</caption>
    <thead>
      <tr><th scope="col">Region</th><th scope="col" class="data-table__num">Revenue</th></tr>
    </thead>
    <tbody>
      <tr><td><a class="data-table__link" href="#north">North</a></td><td class="data-table__num">12,400</td></tr>
      <tr><td><a class="data-table__link" href="#south">South</a></td><td class="data-table__num">9,150</td></tr>
      <tr><td><a class="data-table__link" href="#east">East</a></td><td class="data-table__num">8,020</td></tr>
    </tbody>
  </table>
</div>
--- */

Styled search bars with custom colors, border radius, and icon support

Use the HTML search box generator to build a ready-to-use search form with matching CSS instantly.

A rounded search bar with a search icon on the left, an input and a purple search button

Flexbox · IE11+ · 133 lines
/* Rounded search bar: icon, input and purple button (Flexbox, IE11+) */

/* Variables */
.search-bar {
  --bar-border: #d1d5db;
  --bar-bg: #ffffff;
  --bar-text: #1f2937;
  --bar-placeholder: #6b7280;
  --bar-focus: #7c3aed;
  --btn-bg: #6d28d9;
  --btn-bg-hover: #5b21b6;
}

/* Layout */
.search-bar {
  display: -ms-flexbox;
  display: flex;
  -ms-flex-direction: row;
  flex-direction: row;
  -ms-flex-wrap: nowrap;
  flex-wrap: nowrap;
  -ms-flex-align: center;
  align-items: center;
  box-sizing: border-box;
  width: 100%;
  max-width: 34rem;
  margin: 0 auto;
  padding: 0.5rem 0.5rem 0.5rem 1rem;
  background: #ffffff;
  background: var(--bar-bg, #ffffff);
  border: 2px solid #d1d5db;
  border-color: var(--bar-border, #d1d5db);
  border-radius: 999px;
}

/* Parts */
.search-bar__icon {
  position: relative;
  box-sizing: border-box;
  -ms-flex: 0 0 auto;
  flex: 0 0 auto;
  width: 1.125rem;
  height: 1.125rem;
  margin-right: 0.75rem;
  border: 2px solid #6b7280;
  border-radius: 50%;
}
.search-bar__icon::after {
  content: "";
  position: absolute;
  top: 0.8125rem;
  left: 0.8125rem;
  width: 0.5625rem;
  height: 2px;
  background: #6b7280;
  transform: rotate(45deg);
  transform-origin: left center;
}
.search-bar__input {
  -ms-flex: 1 1 auto;
  flex: 1 1 auto;
  min-width: 0;
  padding: 0.5rem 0.25rem;
  border: 0;
  border-radius: 999px;
  background: transparent;
  font: inherit;
  font-size: 1rem;
  color: #1f2937;
  color: var(--bar-text, #1f2937);
}
.search-bar__input::placeholder {
  color: #6b7280;
  color: var(--bar-placeholder, #6b7280);
  opacity: 1;
}
.search-bar__input:-ms-input-placeholder {
  color: #6b7280;
}
.search-bar__button {
  -ms-flex: 0 0 auto;
  flex: 0 0 auto;
  margin-left: 0.5rem;
  padding: 0.5rem 1.25rem;
  border: 0;
  border-radius: 999px;
  background: #6d28d9;
  background: var(--btn-bg, #6d28d9);
  color: #ffffff;
  font: inherit;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
}

/* States */
.search-bar__button:hover {
  background: #5b21b6;
  background: var(--btn-bg-hover, #5b21b6);
}
.search-bar__input:focus,
.search-bar__input:focus-visible {
  outline: 2px solid #7c3aed;
  outline: 2px solid var(--bar-focus, #7c3aed);
  outline-offset: -2px;
}
.search-bar__button:focus,
.search-bar__button:focus-visible {
  outline: 3px solid #7c3aed;
  outline: 3px solid var(--bar-focus, #7c3aed);
  outline-offset: 2px;
}

/* Media queries */
@media (max-width: 30em) {
  .search-bar {
    padding-left: 0.75rem;
  }
  .search-bar__button {
    padding-right: 0.875rem;
    padding-left: 0.875rem;
  }
}

/* Expected markup:
<form action="/search" role="search">
  <div class="search-bar">
    <span class="search-bar__icon" aria-hidden="true"></span>
    <input class="search-bar__input" type="search" name="q" placeholder="Search…">
    <button class="search-bar__button" type="submit">Search</button>
  </div>
</form>
*/

Frequently Asked Questions

Why Choose AIFreeForever's CSS Generator?

Styling a website takes time, so AIFreeForever's AI CSS Generator writes the stylesheet for you.

01

Free to Use

Generate CSS stylesheets for free in AIFreeForever's chat box.

02

Six CSS Techniques

Pick Modern CSS, Flexbox, CSS Grid, Animations, Responsive Design or Transitions.

03

Browser Support Levels

Choose Modern Browsers, IE11+ or All Browsers with fallbacks and prefixes.

04

Accessible Styles

Every stylesheet adds focus styles, readable text contrast and rem font sizes.

05

HTML Example Included

A comment at the end shows the HTML your class names expect.

06

Download as styles.css

Copy the code or download the finished stylesheet as styles.css.

Generate CSS for Free

Pick a CSS technique and browser support, describe the styling you need, and get your stylesheet from AIFreeForever's CSS Generator.

Related Developer Tools

By the AIFreeForever Research Team Last updated