What is the CSS Triangle Generator?
Generate CSS triangles using the border technique. Pick direction, size, and colour, then copy the minimal CSS with no extra HTML elements.
Everything runs locally in your browser. Adjust the controls above, preview instantly, and copy clean, production-ready CSS — no account, no upload.
Using the CSS Triangle Generator
Everything lives in the panel at the top of this page. There is nothing to install — it all runs right here in your browser.
Pick direction and size
Click the direction arrows (up, down, left, right, or diagonal) and set the size in pixels.
Set the colour
Pick the triangle colour. The two adjacent borders are set to transparent automatically.
Copy the CSS
Click Copy to grab the minimal border-trick CSS. No extra HTML elements needed.
What the generated code looks like
Clean, production-ready CSS — no vendor bloat, no unnecessary declarations.
/* Triangle pointing down */
.triangle-down {
width: 0;
height: 0;
border-left: 20px solid transparent;
border-right: 20px solid transparent;
border-top: 24px solid #6C2EF5;
}
/* Triangle pointing right */
.triangle-right {
width: 0; height: 0;
border-top: 16px solid transparent;
border-bottom: 16px solid transparent;
border-left: 20px solid #6C2EF5;
}
/* Tooltip arrow using ::before */
.tooltip::before {
content: '';
display: block;
width: 0; height: 0;
border-left: 8px solid transparent;
border-right: 8px solid transparent;
border-bottom: 10px solid #1e293b;
margin: 0 auto;
}CSS triangles work by giving an element zero width and height, then setting one coloured border and two transparent borders.
Pro tips for better results
Use clip-path for triangles when you need more control
clip-path: polygon(50% 0%, 0% 100%, 100% 100%) creates a triangle that can have a background, border, and shadow. The border trick only works on solid colour triangles.
Transparent must match the background colour for IE11
On older IE, transparent borders render as black on some elements. If you need IE11 support, set the transparent borders to your background colour explicitly.
CSS triangles work as pseudo-elements for tooltip arrows
Use .tooltip::before or .tooltip::after with the triangle CSS to add directional arrows without extra HTML markup.
Frequently asked questions
From the blog
Read more →Modern CSS techniques every developer should know
A practical tour of the CSS features that replaced yesterday’s hacks.
From design to code without the friction
How visual generators speed up the build without sacrificing clean output.
Writing CSS that scales with your project
Tokens, naming, and structure that keep large stylesheets maintainable.