Toolvito

Works on this device

CSS Generator & Playground

Choose what you want to make, type the values, and copy the CSS. A sample shows the result as you type. You can also paste your own HTML and CSS to see which elements each rule matches.

Choose and type the values

A blend of two or more colours: linear, radial or conic.

0 points up, 90 to the right and 180 down. For a conic gradient it is the angle where the first colour starts.

One stop on each line: a colour, then its place in percent. You may leave the place out. Use 2 to 10 stops.

Your values are worked out in this browser. They are not sent to a server.

Your CSS will show here

Correct the values that are marked, and the result comes back.

How to use the generator

  1. Choose what you want to make in the first menu: a gradient, a shadow, a grid and so on.
  2. Type or choose the values. The sample and the CSS change as you type.
  3. Choose Copy under the CSS to copy it, or Download to save it as a file.
  4. Put the CSS into your own style sheet. The class name in it (.box, .text, .grid or .flex) is only an example: change it to the name you use.

What you can make

  • Gradient: linear, radial or conic, with 2 to 10 colour stops. Use it as a background, as a slow moving background, as a layer over a picture, as the colour of the letters of a text, or as a border.
  • Background pattern: stripes, checks, dots or grid lines made only of gradients.
  • Box shadow and drop shadow, and text shadow with a glow, stacked layers or an outline.
  • Rounded corners, clip path (triangle, star, arrow, circle, your own points), filter and transform.
  • Transition and animation with keyframes, with a speed curve such as cubic-bezier(0.25, 0.1, 0.25, 1) or steps(4, end).
  • Grid and flexbox layouts, also a grid that wraps by itself and a page layout with named areas.
  • Aspect ratio of a box and a fluid size with clamp().
  • Specificity of selectors, and a playground that tries your CSS rules on your HTML.

How the sample is made

The sample is a box or a text that this page builds itself. The values of your result are set on it one by one, after a check that each one is a plain value that cannot load a file. The CSS text itself is never put into the page.

A movement in the sample starts only when you choose Play. A transition also runs when you point at the sample or move the keyboard focus to it.

The sample of a filter has a coloured background so that you can see the change. That background is not part of your CSS.

The playground has no picture

In the playground you paste HTML and CSS. The page reads both as text and lists, for each selector, its specificity and the elements it matches, with their line numbers. A selector that matches nothing is easy to find this way.

The page does not draw your HTML with your CSS. Its safety rules do not let it show styles that were typed in, also not inside a closed frame. So the playground gives you one page file with your HTML and your CSS in it. Download it and open it in your browser to see the picture.

The formula for a fluid size

A fluid size grows in a straight line between two window widths: growth = (largest size − smallest size) ÷ (end width − start width), and start = smallest size − growth × start width. The middle value of clamp() is the start in rem plus the growth × 100 in vw.

Example: from 16 pixels at a window width of 320 pixels to 32 pixels at 1280 pixels, with 1 rem = 16 pixels. Growth = 16 ÷ 960 = 0.016667 pixels for each pixel of width, which is 1.6667vw. Start = 16 − 0.016667 × 320 = 10.667 pixels = 0.6667rem. The result is clamp(1rem, 0.6667rem + 1.6667vw, 2rem). At a width of 768 pixels the size is 23.47 pixels.

More worked examples

  • Aspect ratio: a width of 1920 and a height of 1080 have the greatest common divisor 120, so the ratio is 16:9 and the CSS is aspect-ratio: 16 / 9. The height is 56.25% of the width. For a new width of 1280 the height is 720.
  • Box shadow: move down 8, blur 24, black with 20% opacity gives box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2).
  • Regular polygon: with 6 sides the points lie on a circle around the middle of the box, 60 degrees apart. The first is at the top: polygon(50% 0%, 93.3% 25%, 93.3% 75%, 50% 100%, 6.7% 75%, 6.7% 25%).
  • Specificity: #main nav a:hover has 1 id, 1 pseudo-class and 2 element names, so its specificity is 1,1,2. It is stronger than .card .title (0,2,0).

Limits you should know

  • Each generator makes one effect. To use two effects on one element, copy both results into one rule.
  • A typed number may have at most 3 decimal places, so that it is written exactly as you typed it.
  • Colours are read as hex, rgb(), hsl(), hwb(), lab(), lch(), oklab(), oklch() or a CSS colour name, and are written as hex, or as rgba() when they have opacity.
  • The CSS is written for current browsers, without old prefixes. Two exceptions: the -webkit-background-clip line for gradient text, and a -webkit-clip-path line if you tick the box for it.
  • Every result with movement has a rule that turns the movement off for people who ask their device for less motion. Do not remove it.
  • The contrast figure for a text shadow compares the text colour with the background colour you type. The page cannot check contrast on a gradient or a pattern: check that by eye and with a contrast tool.
  • The playground does not look into @media and other at-rules, and it cannot try a selector with a state such as :hover. Very unusual HTML can be read differently from a browser.
  • A clip path with curves, a masonry layout and a media query are not made here.

Related tools