# How to Make a Triangle in CSS (3 Ways)

> Make triangles in pure CSS with clip-path, the classic border trick, or gradients. Triangles pointing in every direction, equilateral triangles, and tooltip and dropdown arrows.

Author: [Marko Denic](https://markodenic.com/) | Published: 2026-11-09 | Updated: 2026-11-09 | Topics: CSS, Tutorial, Web Development | Canonical: https://markodenic.com/css-triangle/

![How to Make a Triangle in CSS (3 Ways)](https://markodenic.com/wp-content/uploads/2026/11/og-css-triangle.png)

The modern way to make a triangle in CSS is `clip-path`: take any box and cut it to a three-point polygon.

### Triangle with clip-path

The points are `x y` pairs, measured from the top-left corner. This one is the top center, bottom right and bottom left. Because it’s a real box, you can give it a gradient, an image or a transition.

```css
.triangle {
  width: 100px;
  height: 100px;
  background: #1d4ed8;
  clip-path: polygon(50% 0, 100% 100%, 0 100%);
}
```

### Demo:

```html
<div class="tri-demo">
  <div class="tri-demo__cell"><div class="tri-up"></div><span>clip-path up</span></div>
  <div class="tri-demo__cell"><div class="tri-right"></div><span>clip-path right</span></div>
  <div class="tri-demo__cell"><div class="tri-gradient"></div><span>with gradient</span></div>
  <div class="tri-demo__cell"><div class="tri-border"></div><span>border trick</span></div>
  <div class="tri-demo__cell"><div class="tri-corner"></div><span>corner</span></div>
  <div class="tri-demo__cell"><div class="tri-tooltip">Tooltip</div><span>arrow</span></div>
</div>
```

```css
.tri-demo {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 16px;
  padding: 20px;
  border-radius: 16px;
  background: #f1f5f9;
  font: 12px/1.3 ui-monospace, monospace;
  color: #475569;
}

.tri-demo__cell {
  display: grid;
  justify-items: center;
  align-content: end;
  gap: 10px;
  min-height: 110px;
}

.tri-up,
.tri-right,
.tri-gradient,
.tri-corner {
  width: 64px;
  height: 64px;
  background: #1d4ed8;
}

.tri-up       { clip-path: polygon(50% 0, 100% 100%, 0 100%); }
.tri-right    { clip-path: polygon(0 0, 100% 50%, 0 100%); }
.tri-corner   { clip-path: polygon(0 0, 100% 0, 0 100%); }

.tri-gradient {
  background: linear-gradient(#60a5fa, #1e3a8a);
  clip-path: polygon(50% 0, 100% 100%, 0 100%);
}

/* The border trick: zero-size box, three borders */
.tri-border {
  width: 0;
  height: 0;
  border-left: 32px solid transparent;
  border-right: 32px solid transparent;
  border-bottom: 56px solid #1d4ed8;
}

/* Tooltip with an arrow */
.tri-tooltip {
  position: relative;
  margin-bottom: 12px;
  padding: 8px 12px;
  border-radius: 8px;
  background: #0f172a;
  color: #fff;
  font-family: system-ui, sans-serif;
}

.tri-tooltip::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  translate: -50% 0;
  border: 7px solid transparent;
  border-top-color: #0f172a;
}
```

[See the live demo](https://markodenic.com/css-triangle/#demo)

## Triangles in every direction

### clip-path points for each direction

Change the polygon points to change the direction. Corner triangles use three corners of the box.

```css
.up    { clip-path: polygon(50% 0, 100% 100%, 0 100%); }
.down  { clip-path: polygon(0 0, 100% 0, 50% 100%); }
.left  { clip-path: polygon(100% 0, 100% 100%, 0 50%); }
.right { clip-path: polygon(0 0, 100% 50%, 0 100%); }

.top-left     { clip-path: polygon(0 0, 100% 0, 0 100%); }
.bottom-right { clip-path: polygon(100% 0, 100% 100%, 0 100%); }
```

### Equilateral triangle

All three sides equal: the height must be about 0.866 times the width (√3 ÷ 2). `aspect-ratio` keeps that ratio at any size. See how [`aspect-ratio`](https://markodenic.com/css-aspect-ratio/) works.

```css
.equilateral {
  width: 100px;
  aspect-ratio: 1 / 0.866;
  background: #1d4ed8;
  clip-path: polygon(50% 0, 100% 100%, 0 100%);
}
```

## The border trick

Before `clip-path`, every CSS triangle used borders, and you’ll still see it everywhere. It works because borders meet at a diagonal: on a box with no width or height, each border is a triangle.

### How it works

Make the box zero-sized, give it a colored border on one side and transparent borders on the two sides next to it. The colored border is the triangle; the transparent ones set its width. The triangle points *away* from the colored side.

```css
/* Points up: color the bottom border */
.triangle-up {
  width: 0;
  height: 0;
  border-left: 50px solid transparent;
  border-right: 50px solid transparent;
  border-bottom: 80px solid #1d4ed8;
}

/* Points down: color the top border */
.triangle-down {
  width: 0;
  height: 0;
  border-left: 50px solid transparent;
  border-right: 50px solid transparent;
  border-top: 80px solid #1d4ed8;
}
```

### Tooltip and dropdown arrows

The border trick is still the simplest way to add an arrow to a tooltip or dropdown, using a [::after pseudo-element](https://markodenic.com/css-before-after/). A box with transparent borders on all sides and one colored side gives a neat arrow.

```css
.tooltip {
  position: relative;
  background: #0f172a;
}

.tooltip::after {
  content: "";
  position: absolute;
  top: 100%;            /* just below the tooltip */
  left: 50%;
  translate: -50% 0;
  border: 7px solid transparent;
  border-top-color: #0f172a;  /* points down */
}
```

## Other ways

### A rotated square

Rotate a square 45° and hide half of it inside its parent. Unlike the other methods, this one can have a real border and a shadow, which is why it’s often used for speech-bubble arrows with outlines.

```css
.bubble::before {
  content: "";
  position: absolute;
  bottom: -8px;
  left: 24px;
  width: 16px;
  height: 16px;
  background: #fff;
  border-right: 1px solid #cbd5e1;
  border-bottom: 1px solid #cbd5e1;
  rotate: 45deg;
}
```

### A gradient triangle

A hard-stop `linear-gradient` splits a box diagonally, so half of it is a right triangle. Useful as a background decoration without extra elements, just like [CSS stripes](https://markodenic.com/css-striped-background/).

```css
.corner-ribbon {
  background: linear-gradient(to top right, transparent 50%, #1d4ed8 50%);
}
```

## Which method to use

- **clip-path**: the default. Any size, any background, easy to animate, and the shape scales with the box.
- **Border trick**: small arrows on tooltips and dropdowns, solid color only.
- **Rotated square**: when the arrow needs a border or shadow.
- **SVG**: for icons and complex shapes, an inline `<svg>` with a `<polygon>` is often clearer than any CSS trick.

## FAQ

### How do I make a triangle in CSS?

Give an element a width, height and background, then `clip-path: polygon(50% 0, 100% 100%, 0 100%)`. That’s an upward-pointing triangle.

### Can a CSS triangle have a border?

Not with `clip-path` or the border trick, since `clip-path` cuts the border off too. Stack two triangles (a bigger one behind in the border color), use a rotated square with borders, or use SVG with a `stroke`.

### Can I add a shadow to a triangle?

`box-shadow` follows the box, not the triangle. Use `filter: drop-shadow()` on the parent instead; it follows the visible shape.

### How do I make a triangle pointing down?

`clip-path: polygon(0 0, 100% 0, 50% 100%)`, or with the border trick, color the `border-top`.

Related: [CSS ::before and ::after](https://markodenic.com/css-before-after/), [CSS transform](https://markodenic.com/css-transform/), [striped backgrounds](https://markodenic.com/css-striped-background/) and [CSS tips](https://markodenic.com/css-tips/).
