.triangle {
width: 0;
height: 0;
border-left: 50px solid transparent;
border-right: 50px solid transparent;
border-bottom: 80px solid #6366f1;
}Direction: Up
Method
Use as
How to use
Pick a direction
Click one of the eight arrows in the direction picker. Up, down, left and right make isosceles triangles; the corner directions make right-angled ones.
Set size, color and method
Drag Width and Height, or switch on Equilateral, and choose a color. Pick Border trick or clip-path, and Shape or Tooltip arrow.
Copy the code
Pick CSS, HTML, CSS + HTML or Tailwind and press Copy or Download. Copy share link saves the settings in a URL.
Why CSS Triangle Generator
- Eight directions, including right-angled corner triangles.
- Border trick or clip-path output, with exact sizes and an equilateral option.
- A tooltip arrow mode that writes the ::after rule and its position.
- CSS, HTML and Tailwind output with a live preview.
Border widths for each direction
For a triangle of width W and height H, the border trick sets these borders on a zero-size box. The colored border is the one opposite the point.
| Direction | Colored border | Transparent borders |
|---|---|---|
| Up | border-bottom: H | border-left and border-right: W / 2 |
| Down | border-top: H | border-left and border-right: W / 2 |
| Left | border-right: W | border-top and border-bottom: H / 2 |
| Right | border-left: W | border-top and border-bottom: H / 2 |
| Up left | border-top: H | border-right: W |
| Down right | border-bottom: H | border-left: W |
The same triangles with clip-path
With clip-path the box keeps its real size and the polygon cuts it. Percentages keep the shape correct at any size.
- Up: polygon(50% 0, 100% 100%, 0 100%)
- Down: polygon(0 0, 100% 0, 50% 100%)
- Left: polygon(0 50%, 100% 0, 100% 100%)
- Right: polygon(0 0, 100% 50%, 0 100%)