Skip to content

Free CSS Triangle Generator

Choose a direction, size and colour to get a triangle made with nothing but CSS, in two flavours of code.

  • 100% free
  • Runs in your browser
  • Instant results
Quick answer

A CSS triangle generator produces the code for a triangle drawn without an image. Choose one of eight directions, set the width, height and colour, and the tool shows a live preview and gives you two versions to copy: the classic border technique and a modern clip-path polygon.

How to use the CSS Triangle Generator

  1. Pick a directionChoose up, down, left or right for an arrow, or one of the four corner triangles.
  2. Set size and colourDrag the width and height sliders and choose the fill colour.
  3. Copy the CSSCopy the border version for the widest support, or the clip-path version if you need gradients or images inside the shape.

How the border triangle trick works

Where two borders of an element meet, the browser joins them with a diagonal line. Give an element a width and height of zero and thick borders, and each border becomes a triangle pointing to the centre. Make three of them transparent and one triangle is left. That is what the CSS triangle generator writes:

  • For an upward triangle, the left and right borders are transparent and each is half the width; the bottom border is coloured and as thick as the height.
  • For down, the coloured border is on top. For left and right, the top and bottom borders are transparent and each is half the height.
  • Corner triangles (right-angled) need only two borders: one coloured, one transparent.

The colour always goes on the border opposite the point. This technique works in every browser ever likely to visit your site, which is why tooltips and dropdown arrows have used it for years.

Border method or clip-path?

The second code block uses clip-path: polygon(). Here the element keeps a real width, height and background, and the polygon cuts away everything outside three points. Compare the two:

  • Border method: universal support and tiny code, but the element has no content area, so it can only be a single flat colour.
  • Clip-path method: the triangle can hold a gradient, an image or even text, and its size can be animated or set in percentages. It is supported by all current browsers.

Neither method can show a box-shadow: with borders the shadow follows the zero-size box, and clip-path cuts the shadow off. Use filter: drop-shadow() on the element (border method) or on its parent (clip-path method) instead.

Typical use: attach the triangle to a tooltip or speech bubble with a ::after pseudo-element, set content: "" and position: absolute, and move it to the edge of the box. Round the bubble itself with the border radius generator, and shrink your finished style sheet with the CSS minifier.

Frequently asked questions

How do I make a triangle in CSS?

Set width and height to 0, make two side borders transparent and give the third border a colour. The CSS triangle generator writes the exact values for any size and direction.

How do I add an arrow to a tooltip?

Put the triangle code on the ::after pseudo-element of the tooltip, add content: "" and position: absolute, then place it on the edge with top, left or bottom.

Can a CSS triangle have a border or shadow?

Not directly. Use filter: drop-shadow() for a shadow. For an outline, stack a slightly larger triangle in the border colour behind the first one.

Which method should I use, border or clip-path?

Use the border method for simple solid arrows. Use clip-path when the triangle needs a gradient, an image, percentage sizing or animation.

How do I change the triangle size?

Change the border widths. In an upward triangle, the bottom border is the height and the two side borders are each half of the width.

Last updated 24 November 2026 by the TheTechFolk team.