Skip to content
Jellykit

CSS Triangle Generator

Make CSS triangles with borders or clip-path in eight directions, or a tooltip bubble with its arrow.

  • Runs on your device
Loading tool

About CSS Triangle Generator

Pick a direction, a width, a height and a color, and copy a triangle made of plain CSS. Choose the border technique for an empty element that works everywhere, or clip-path for a real box you can fill with a gradient or image.

Switch to tooltip arrow to get a speech bubble with an ::after arrow on any side, placed anywhere along that side, with the arrow size and corner radius you choose.

How it works

  1. With borders, the element has no size of its own. Its borders meet on diagonal lines, so coloring one border and making its neighbours transparent leaves a triangle.
  2. The colored border sets the height of the triangle and the transparent ones set its base, so the outer box is exactly the width and height you chose.
  3. With clip-path, the element keeps its full size and a polygon of three points cuts it to shape, given in percentages so it scales with the box.
  4. A tooltip arrow is a border triangle in an ::after pseudo-element, positioned just outside the chosen side of the bubble and centred on the point you set.

Questions

Which technique should I use?

Borders give a solid color and work in every browser, even very old ones. Clip-path keeps a real box, so the triangle can have a gradient or image background and a size set in any unit.

Can the tooltip arrow have a border or a shadow?

Not as generated. A border triangle is made of borders, so it cannot have one of its own. A common approach is a second, slightly larger arrow behind it in a ::before element.

Why does the triangle look jagged in some browsers?

Diagonal edges are anti-aliased by the browser. Very thin or very long triangles show it most; whole-pixel sizes usually look cleanest.

Everything you enter here is processed in this browser tab. Nothing is uploaded, logged or shared. How privacy works here.