How the border trick works
A box’s borders meet at its corners along a diagonal line. With a width and height of zero there’s no box left in the middle, only the four borders, and each one is drawn as a triangle pointing at the centre. Making three of them transparent leaves a single coloured triangle. The border on the side opposite the point sets its height, and the two borders either side of it set how wide it is. That’s why a triangle pointing up is written with a bottom border: the colour sits where the base of the triangle is.
Choosing a method
Border triangles have been used for arrows and carets for twenty years and work everywhere, but a border can only be one colour. clip-path: polygon() starts from an ordinary box with a real width and height and cuts away everything outside the three points, so the triangle can be filled with a gradient, an image or anything else a background can hold. The ::after output is a border triangle drawn by a pseudo-element, which keeps small decorations out of your HTML. SVG is the choice for icons that have to scale cleanly or be used as an image.
Arrows on real elements
Most CSS triangles aren’t used on their own. They point out of a tooltip, hang off a speech bubble, sit next to a menu label or turn a label into a step in a progress bar. Picking one of those at the top shows the triangle on that element at its real size, and the code includes the element’s own styles so it works when pasted. The arrow is placed just outside the side it points out of, and it’s centred along that side unless you move it to the start or the end.
Any triangle, not just eight directions
The direction grid covers the triangles people need most often. For a plain triangle, Free-form mode covers the rest: drag the three corners anywhere, or move them with the arrow keys. The width and height fields stretch the shape, and the readout shows its size and all three angles. For border output the generator picks the longest side as the base, so none of the border widths is ever negative, and rotates the triangle into place.
Nothing leaves your browser
There’s no server behind this tool. The preview is drawn by your own browser and the code is written in the page as you work. The share link keeps its settings after the #, a part of the address that browsers don’t send anywhere.