CSS Triangle Generator

Build a triangle or arrow in pure CSS using the classic border trick — no images or SVG. Pick a direction, set the width, height, and color, then copy ready-to-paste code for tooltips, carets, dropdown arrows, and ribbons.

Direction

Presets

Size & Color

100px
80px
#6366f1

CSS Code

How CSS Triangles Work: The Border Trick

CSS has no native "triangle" shape, yet triangles are everywhere — dropdown carets, tooltip pointers, ribbon ends, play buttons, and accordion arrows. The trick that powers nearly all of them is clever use of borders on a zero-size element.

Why It Works

When an element has width: 0 and height: 0, its four borders meet at the centre point and each border becomes a triangle wedge. Where two borders meet, they form a diagonal seam. If you make three of the four borders transparent and give the fourth a solid colour, only that one wedge is visible — and it's a perfect triangle. The direction the triangle points is the opposite of the coloured border: a coloured bottom border points up.

The Four Cardinal Directions

Right-Angle & Corner Triangles

Using only two borders instead of three produces a right-angled triangle that fills a corner — ideal for ribbon flags and folded-corner effects. For example, a coloured top border plus a transparent right border yields a triangle anchored in the top-left corner. The four diagonal directions in this generator output exactly these two-border shapes.

Common Uses & Tips

Because the shape is built from borders, you can't apply border-radius to soften the tip — reach for clip-path if you need rounded or more complex polygons instead. For crisp edges on high-DPI screens, keep the pixel values whole numbers.

Frequently Asked Questions

Give an element width: 0; height: 0; and set three of its four borders to transparent with the fourth a solid colour. The visible border wedge forms a triangle. This generator writes that code for you in any of eight directions.
It points away from the coloured border. A coloured bottom border makes an upward triangle, a coloured top border makes a downward one, and so on. Just pick the arrow you want in the direction pad.
Generate a small triangle here, then place it on a ::before or ::after pseudo-element of your tooltip with absolute positioning so the point touches the bubble. Match the triangle colour to the tooltip background.
Not with the border trick — border-radius has no effect on it. For rounded or more complex shapes, use a clip-path: polygon() instead, which our clip-path generator can build.
No. They're pure CSS — just borders on a zero-size box. That makes them resolution-independent, instantly recolourable, and free of any extra network requests.