Generated CSS

CSS Triangle Generator

CSS triangles are created using the border trick — a zero-width, zero-height element with thick borders. When three sides are transparent and one is colored, the visible border forms a triangle. This is pure CSS with no images, no SVG, and no extra HTML elements.

How the CSS Triangle Trick Works

/* Triangle pointing right */
.triangle {
  width: 0;
  height: 0;
  border-top: 40px solid transparent;
  border-bottom: 40px solid transparent;
  border-left: 60px solid #7c6fff;
}

Common Use Cases

ShapeUse case
Up / Down triangleSort indicators, accordion arrows, dropdown icons
Left / Right triangleCarousel arrows, next/prev buttons, breadcrumbs
Corner triangleRibbon badges, "NEW" banners, notification corners
Speech bubble tailTooltips, chat bubbles, popover arrows

Frequently Asked Questions

Can I add a border to a CSS triangle?

Not directly — borders on borders don't work. The solution is to layer two triangles: a slightly larger one in the border color underneath the main triangle. Use ::before and ::after pseudo-elements for a single-element implementation.

Should I use CSS triangles or SVG?

For simple directional arrows in UI, CSS triangles are fine and have zero network cost. For complex shapes, icons, or anything that needs to scale cleanly at unusual sizes, SVG is better. The CSS border trick is a widely supported, zero-dependency solution.

How do I center a CSS triangle?

CSS triangles have no natural center since their visual size differs from their width/height (which are both 0). Use a wrapper element with display: flex; align-items: center; justify-content: center; to center the triangle visually.

Related tools: CSS Clip Path Generator · Border Radius Generator

Tool last updated: