CSS

CSS Triangle Generator

Details

How to use CSS Triangle Generator

What the tool does, how to run it, and what to expect from the result.

How to make a CSS triangle

A CSS triangle is built by giving an element no width and no height, then making three of its four borders do the work: two transparent, one solid. Where the transparent borders meet the solid one, the browser draws a diagonal, and a triangle is what is left.

The preview shows a live element with the generated borders. It is worth knowing that clip-path now does the same job more flexibly, so reach for this when you specifically want a markup-free caret.

  • Choose the direction the triangle should point.
  • Set the size, which controls the half-width of the base through the transparent borders and the height through the solid one.
  • Pick the fill colour, which is applied to the single solid border.
  • Copy the declaration block, which sets width and height to zero and defines the three borders.
  • Apply it to an empty element, such as a pseudo-element on a tooltip or a dropdown, since the triangle cannot hold content of its own.
Tips

Getting a better result out of CSS Triangle Generator

Specific settings and thresholds, not general advice.

  • The border trick works because adjacent borders meet at a 45-degree diagonal. Give an element zero width and height, make two borders transparent and one solid, and what remains is a triangle. It is a rendering artefact turned into a technique, which is why it looks like nothing you would ever guess.
  • In 2026 you probably want clip-path instead. clip-path: polygon(50% 0%, 0% 100%, 100% 100%) draws the same triangle, works on any element, allows real width and height, can hold content, can be animated, and is supported everywhere. The border trick survives mostly out of habit.
  • A triangle made this way cannot contain anything. The element has zero width and zero height, and the whole shape is border, so there is no content box to put text in and no way to give it a background image.
  • You cannot round the tip. border-radius has no effect on a triangle built from borders, so if your design calls for a softened point, clip-path with a rounded polygon or an inline SVG is the only route.
  • The diagonal edges are antialiased by the browser and can look slightly ragged at small sizes, particularly on non-retina displays. If the triangle is a tiny dropdown caret, an inline SVG or a text arrow character will usually render more crisply.
Limits

What CSS Triangle Generator does not do

The honest boundary, so you do not lose time finding it yourself.

  • The generated element has zero width and height, so it cannot contain text or any child content.
  • It cannot be rounded, since border-radius does not apply to a border-drawn triangle.
  • It produces only the four axis-aligned directions, with no arbitrary angles, no scalene shapes, and no other polygons.
  • It cannot carry a gradient or an image fill, because the shape is made of a solid border colour.
At a glance

Who CSS Triangle Generator is for

A quick way to understand who this helps, what it solves, and where it connects next.

Best fit

Frontend developers, designers, and anyone styling web pages.

Ideal for

Quickly building border CSS visually without writing it by hand.

FAQ

Common questions

Short answers for the questions people usually have before trying a utility like this.

Is the CSS triangle generator free?

Yes. It is completely free to use, with no signup, no account, and no paywall.

Can I use the generated CSS in commercial projects?

Yes. The CSS you copy from the tool is yours to use in any project, personal or commercial, with no attribution needed.

Does it stay local?

Yes. Everything runs in your browser, and nothing you configure is uploaded to a server.

Should I still use the border trick, or clip-path?

clip-path, for almost every new use. clip-path: polygon() draws the triangle from three coordinates that read exactly like what they describe, works on an element that keeps its real width and height, can contain content, accepts a gradient or an image as a background, and can be animated between shapes. The border trick predates it by a decade and survives because it is in everybody's muscle memory. The one place the old technique still earns its keep is a tiny CSS-only caret where you want no extra markup at all.

Why can I not put text inside my triangle?

Because there is no inside. The element is declared with width: 0 and height: 0, and the visible shape is made entirely of border. There is no content box at all, so any child you add would be positioned at a single point and would overflow in every direction. If you need a triangular container with content in it, clip-path is the answer, since it clips a normal element rather than replacing it with a border.

How do I control the triangle's proportions?

The two transparent borders set the half-width of the base and the solid border sets the height. So the base is twice the transparent border width, and the height is whatever you give the solid one. To make a wider, flatter triangle, increase the transparent borders relative to the solid one. To make a tall, narrow spike, do the reverse. Equilateral is not the default, so if you need one, the solid border should be roughly 1.73 times the transparent ones.

Can I add a border or a shadow to the triangle?

Not directly, and this is where the technique really shows its age. The whole shape is already made of border, so there is no border left to add. A drop shadow can be faked with the filter: drop-shadow() function, which follows the painted shape rather than the box, and that does work. An outline around the triangle needs a second, slightly larger triangle stacked behind it, or a switch to SVG.

Does the preview run in my browser?

Yes. The triangle you see is a real element with the generated borders applied, so it renders exactly as it will on your page, and nothing is sent to a server.

Recommendations

You Might Also Like

Nearby tools from the catalog that fit the same job or workflow.

Cleanor app

Do it all on your device

Cleanor puts these tools in one app: compress and convert images, video, and audio, work with PDFs, and scan text right on your device. Plus free up storage and clear inbox clutter with Email Cleaner. Start with a free trial.

  • iPhone
  • Android
  • Macsoon
  • Windowssoon