CSS Triangle Generator

Make a triangle with pure CSS in any of eight directions, with the width, height and colour you choose, and a live preview.

Processed on your device. Files are not uploaded

How to make a triangle with CSS

  1. Choose the direction

    Up, down, left, right or a corner.

  2. Set the size and colour

    Enter the width, height and colour and watch the preview.

  3. Copy the CSS

    Paste the .triangle rule into your stylesheet.

Worked example

This is what CSS Triangle Generator gives for its own sample values. Open the tool above and change anything to try your own.

Points
Up
Width (px)
100
Height (px)
80
Colour
#0f766e

CSS

.triangle {
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 0 50px 80px 50px;
  border-color: transparent transparent #0f766e transparent;
}

About CSS Triangle Generator

Make a triangle with a few lines of CSS. The element has no size and thick borders that meet at a point, with the unwanted borders transparent. It is handy for tooltip arrows, menus and speech bubbles.

FAQs

Can I give it a border or shadow?

Not with this trick. Use clip-path: polygon() when you need that.

Does it need extra HTML?

Only an empty element, or a ::before or ::after pseudo-element.

How do I make a tooltip arrow?

Position the triangle with absolute positioning at the edge of the tooltip.

Related tools