Free CSS Triangle Generator
The Triangle Generator produces CSS-only triangles using the classic border technique. Choose a direction, size, and color, then copy the CSS.
Triangles are usually one element in a larger effect, alongside the CSS Clip-Path Maker and the CSS Border Radius Generator. The surrounding layout is easier to reason about with the CSS Flexbox Generator and CSS Grid Generator.
How to use the CSS Triangle
- 1 Choose the direction the triangle should point.
- 2 Set the width and height, which control the size of the shape.
- 3 Pick the colour.
- 4 Copy the generated CSS.
Where the technique still earns its place
The border triangle survives because it needs nothing but CSS on an existing element. Tooltips use it for the pointer, dropdowns for the arrow, and any number of decorative accents are built from it. Adding an SVG would mean adding markup, and for a shape this simple the CSS is shorter.
Its limitation is that it is one shape with no outline of its own. A triangle that needs a visible border requires two stacked triangles, one slightly larger in the border colour behind the other. At that point the SVG becomes the simpler answer.
- Zero width and height with one opaque border and three transparent.
- The border width sets the triangle's height; the adjacent widths set its base.
- Rotate a single triangle to point in any direction.
- Use SVG once you need a border or an animation.
Frequently asked questions
How does a triangle made of borders work?
The trick is that a border meets its neighbours at a diagonal. If an element has zero width and height but a wide border on one side and transparent borders on the others, the visible border is a triangle. The transparent borders are what cut the shape out of what would otherwise be a trapezoid.
Why can a border triangle look slightly ragged?
Because the diagonals are anti-aliased by the browser, and at certain sizes the edges pick up a fringe. It is a rendering artefact rather than a mistake. If it is visible, using a slightly larger triangle and scaling it with a transform usually hides it.
Is a border triangle still the best approach?
For a simple arrow or marker, yes — it needs no extra markup and no image. For anything more complex, an inline SVG is cleaner, because it scales without artefacts, supports a border, and can be animated as a path. The border technique is a shortcut for exactly one shape.
Related Developer Tools
You might also need
Tools from other categories that people pair with the CSS Triangle: