CSS Triangle Generator

Visually design pure CSS triangles using the border trick. Perfect for tooltips, dropdown arrows, and UI accents.

#3B82F6
width: 0;
height: 0;
border-style: solid;
border-width: 0 25px 50px 25px;
border-color: transparent transparent #3B82F6 transparent;

About the CSS Triangle Generator

Choose a direction, size and colour, and get the CSS for a triangle made from borders – the classic way to draw tooltip arrows and dropdown carets.

Everything you enter is processed in your browser; nothing is uploaded or stored.

How to use it

  1. Choose the direction the triangle points.
  2. Set the width, height and colour.
  3. Copy the CSS and apply it to an empty element or a ::before/::after pseudo-element.

How a border triangle works

An element with zero width and height still draws its borders, and where two borders meet they are cut diagonally. Make three borders transparent and colour one, and only a triangle is left.

For an upward triangle: border-width: 0 (w/2) h (w/2); border-color: transparent transparent colour transparent; – the coloured bottom border becomes the triangle.

Example

A 20 px wide, 10 px tall downward triangle under a tooltip: width 0, height 0, border-width 10px 10px 0 10px, border-color #333 transparent transparent transparent.

Frequently asked questions

How do I add an arrow to a tooltip?

Put the triangle CSS on the tooltip’s ::after pseudo-element and position it absolutely at the edge.

Is there another way to make triangles?

clip-path: polygon() also works and supports borders and shadows more easily, but the border method has the widest support.

Can the triangle have a border?

Stack two triangles: a slightly larger one in the border colour behind the main one.