CSS Triangle Generator
There are two clean ways to draw a triangle in CSS. The classic trick gives a zero-size box thick borders and makes all but one of them transparent. The modern way gives a normal box a size and a background, then cuts it with clip-path: polygon() using three points. This generator writes both for eight directions.
| Need | Border method | clip-path |
|---|---|---|
| Solid one-colour arrow | Works everywhere | Works everywhere current |
| Gradient or image fill | No, borders take one colour each | Yes, it clips any background |
| Outline only | Stack two triangles | Not directly; clip-path also cuts off borders and shadows |
| Size set by width and height | No, sized by border widths | Yes |
| Tooltip arrow on ::before or ::after | The usual choice | Also fine |
Updated
Arrows on tooltips, speech bubbles, dropdown carets and ribbon corners are almost always small CSS triangles. Choose a direction, drag the size, and the preview shows both techniques side by side so you can see they match before copying the one that fits your component.
Triangle builder
Choose a direction, set the size and colour, and compare the border triangle with the clip-path triangle before copying.
Tooltip arrow with a pseudo-element
Bubble with a downward arrow
The ::after element has no size. Its top border is the arrow and the side borders are transparent.
<style>
.tip { position: relative; display: inline-block; margin: 20px; padding: 10px 14px;
background: #0f172a; color: #fff; border-radius: 8px; }
.tip::after { content: ""; position: absolute; top: 100%; left: 24px;
border-top: 10px solid #0f172a;
border-left: 8px solid transparent;
border-right: 8px solid transparent; }
</style>
<span class="tip">Saved to your drafts</span>Gradient triangle with clip-path
A border triangle cannot take a gradient. A clipped box can, because clip-path cuts whatever background the box paints.
<style>
.tri { width: 140px; height: 121px; margin: 10px auto;
background: linear-gradient(135deg, #4F98FB, #ec4899);
clip-path: polygon(50% 0, 100% 100%, 0 100%); }
</style>
<div class="tri"></div>
Pick the method by what the triangle is for
For a tiny arrow that sticks out of a tooltip or menu, the border method is still the shortest code, and it lives comfortably on a pseudo-element. It has one colour and its size comes from border widths, which is all an arrow needs.
For a decorative shape, a hero corner or anything with a gradient, clip-path is easier to reason about: you set width and height like any box and describe the three corners as percentages.
Corner triangles
Corner triangles are right-angled and fill one half of a rectangle. With borders you colour one side and make one adjacent side transparent, leaving the other two at zero. They are handy for folded paper corners and ribbon tails.
How it works
- Choose a direction: up, down, left, right or one of the four corner triangles.
- Set width, height and colour. The equilateral button sets the height to width times 0.866.
- Compare the two previews, then copy the border version, the clip-path version or the Tailwind classes.
Tips
- In the border method, the coloured side's border width becomes the triangle's height and the two transparent sides each take half the base.
- Use clip-path when the triangle needs a gradient, a picture or a hover colour change on a sized box.
- For tooltip arrows, position the triangle with position: absolute on a pseudo-element so it adds no extra markup.
- Need more than three points? The clip-path generator lets you drag every corner of a polygon.
Frequently asked questions
How does the border triangle trick work?
Where two borders meet, the browser draws the corner on a diagonal. With width and height at 0, the box is nothing but four border wedges meeting in the middle. Colour one wedge and make its neighbours transparent and you see a single triangle.
How do I make an equilateral triangle?
The height of an equilateral triangle is its base times the square root of 3 divided by 2, about 0.866. For a 100 pixel base, use a height of about 87 pixels.
Can a CSS triangle have a border or outline?
Not on its own. A common approach is to stack two triangles: a slightly larger one in the outline colour behind, and the fill colour on top, offset by the outline thickness. An inline SVG with a stroke is simpler when you need a crisp outline.
Does clip-path change the element's layout box?
No. The element keeps its full rectangular size in the layout; clip-path only changes what is painted. Content outside the polygon, including box shadows and borders, is cut away.
How do I write a clip-path triangle in Tailwind?
Use an arbitrary property with underscores for spaces, such as [clip-path:polygon(50%_0,100%_100%,0_100%)], together with sizing and colour classes like w-[40px] h-[30px] bg-[#4F98FB].
Related: Clip-path generator, CSS tooltip generator, CSS masks and shapes, CSS border generator, CSS box model guide.
Start for free or see all free tools. We.Inc is free to start, with no card needed. AI building is on paid plans from $20 a month.
More in Free Tools
- CSS Wave Generator
- CSV to HTML Table Converter
- CSV to JSON Converter
- Cubic Bezier Easing Generator
- Customer Feedback Form Generator With a Question Bank
- Design Prompt Generator
- Free Digital Business Card Maker
- Free Digital Catalog Maker with a WhatsApp Order Button on Every Product
Product
Who It's For
- For Agencies
- For Freelancers
- For Hosting Providers
- For SaaS Platforms
- For Startups
- For Financial Services
- For Healthcare
Features
Resources
- Blog
- Help Center
- Free Business Tools
- Free UI Components
- Website Templates
- Template Collections
- Website Examples
- Guides
- Comparisons
- Alternatives
- Best Lists
- Reviews
- Pricing Guides
- Use Cases
- Glossary & Guides
- Integrations
- Developers
- Benchmark
- Windows App