CSS Triangle Generator

Make a CSS triangle in eight directions with the classic border technique, and get a clip-path alternative. Set width, height and colour and see a live preview.

Use the tool

Why this tool exists

Tooltips, dropdown arrows and speech bubble tails are often drawn with a zero-size element and clever borders. The trick works, but the border values depend on direction and are hard to remember: which sides are transparent, which carries the colour, and what half the width is.

Choose a direction, a width, a height and a colour, and the tool writes the exact declarations. The eight options cover the four arrow directions and the four corner triangles. You also get a clip-path polygon version, which is easier to reason about, can hold a background or gradient, and works for content. The border version has the smallest footprint and is supported everywhere. Preview it in the page, then copy the CSS. Nothing is uploaded.

How to use it

  1. Choose a direction, such as up, down or top-left.
  2. Set the width and height in pixels and pick a colour.
  3. Check the preview.
  4. Copy the border technique CSS or the clip-path version.

Frequently asked questions

Which version should I use?

The border technique is tiny and works in every browser. clip-path is easier to adjust, allows gradients and can clip real content, but it clips box shadows and borders too.

Why is the element width 0?

The triangle is made from the element's borders, so the element itself has no width or height. The border sizes define the shape and the visible area.

How do I add a border or shadow to the triangle?

The border trick cannot easily have an outline. Use a second, slightly larger triangle behind it, or use clip-path on a wrapper with a filter drop-shadow.

How do I use it for a tooltip arrow?

Put it in a ::before or ::after pseudo-element of the tooltip, set position absolute and place it at the edge of the box with top, left or bottom offsets.