CSS Triangle Generator

Make a triangle with the border trick.


The element has no width or height. Three borders are transparent and one border is colored, which leaves a triangle. It is a classic trick and needs no SVG.

Frequently asked questions

Can I put text in it?

Not reliably. Use an SVG or a clip-path polygon when the triangle has to contain text.

Why is the width zero?

The borders meet in the middle of a zero-size box. Giving the box a width would turn the triangle into a trapezoid.