{ CSS Triangle Generator }

// create directional triangles with pure css borders

Generate directional CSS triangles using pure border techniques. Choose direction, size, and color — get clean copy-paste CSS instantly. No images needed.

Width: 60px Height: 60px
// LIVE PREVIEW
// CSS OUTPUT

HOW TO USE

  1. 01
    Pick a direction

    Click one of the 8 directional buttons in the compass grid to set your triangle's pointing direction.

  2. 02
    Adjust size & color

    Use the sliders to set width, height, and color. The live preview updates instantly.

  3. 03
    Copy CSS

    Switch between Element, ::before pseudo-element, or SCSS Mixin output, then click Copy All.

FEATURES

8 Directions Live Preview Pure CSS SCSS Mixin No Images ::before Output

USE CASES

  • 🔺 Tooltip arrows and speech bubble tails
  • 🔺 Decorative section dividers
  • 🔺 Dropdown menu indicators
  • 🔺 Chevron-style UI icons
  • 🔺 Pricing table corner accents

WHAT IS THIS?

CSS triangles are created using a zero-size element with transparent borders on three sides and a colored border on one side. This generator builds the exact border values for any direction, size, and color — no JavaScript or images needed at runtime.

RELATED TOOLS

FREQUENTLY ASKED QUESTIONS

How does the CSS border triangle trick work?

When an element has zero width and height, its borders form four triangles meeting at the center. By setting three borders to transparent and one to a color, you isolate a single triangle. The size of each border controls the triangle's dimensions.

Can I make an equilateral triangle in CSS?

Yes — for an upward pointing equilateral triangle, set the left and right borders to width/2 and the bottom border to width * 0.866. This generator's width/height sliders let you fine-tune exact proportions.

When should I use ::before instead of a real element?

The ::before pseudo-element is ideal when the triangle is decorative (tooltip arrow, divider accent) and you want to avoid adding extra HTML. Switch to the "::before" tab to get that output.

Does this work in all browsers?

CSS border triangles are supported in all modern browsers and Internet Explorer 8+. They are one of the most compatible CSS techniques available — no prefixes needed.

Can I animate CSS triangles?

Yes. You can animate border-color, border-width, and even combine with transform: rotate(). Because triangles are pure CSS, they work seamlessly with CSS transitions and keyframe animations.

What's the difference between diagonal and straight triangles?

Straight triangles (up, down, left, right) use one non-zero border plus two equal transparent sides. Diagonal triangles (top-left, top-right, etc.) use two adjacent non-zero borders on the same corner, creating a right-angle triangle.

What is a CSS Triangle Generator?

A CSS Triangle Generator is an online tool that produces ready-to-paste CSS code for creating triangles using nothing but HTML and CSS borders. Instead of using images, SVGs, or icon fonts, pure CSS triangles leverage a clever browser rendering quirk: when a block element has width: 0 and height: 0, its four CSS borders form four triangular wedges meeting at the center. By coloring one border and making the rest transparent, you isolate a single perfect triangle.

💡 Looking for premium CSS templates and UI kits? MonsterONE offers unlimited downloads of templates, UI kits, and assets — worth checking out.

How Does the CSS Border Triangle Technique Work?

Every CSS box model element has four borders: top, right, bottom, and left. Normally these are rectangular and we rarely notice how they meet at the corners. But when you reduce an element to zero dimensions, those border corners become visible as diagonal lines — and the four borders form four right triangles sharing a common center point.

To create an upward-pointing triangle, for example, you set the element to width: 0; height: 0, then apply a transparent left border, a transparent right border, and a colored bottom border. The left and right transparent borders determine the triangle's horizontal width, and the bottom colored border determines its height. The result is a clean triangle rendered entirely by the browser's layout engine.

Directional Triangles Explained

This generator supports eight triangle directions — four cardinal and four diagonal:

All eight directions are generated using the same zero-size border trick — only the which borders are colored versus transparent changes between them.

CSS Triangle vs SVG: Which Should You Use?

Both approaches have legitimate use cases in modern front-end development:

For tooltip arrows, dropdown indicators, and section dividers, CSS triangles remain the most performant and compatible choice. For complex UI illustrations, SVG wins.

Using the ::before Pseudo-Element for Triangles

One of the most powerful patterns is combining CSS triangles with pseudo-elements. By applying the triangle styles to ::before or ::after, you can attach a triangle to any element without adding extra HTML. This is how most CSS-only tooltips work: the tooltip container is a div, and its ::before provides the pointing arrow below the box.

The generator's ::before tab outputs this exact pattern — complete with content: "", position: absolute, and the border values — ready to paste into your existing selector.

SCSS Mixin for Reusable Triangles

When you use triangles throughout a project, it pays to abstract the values into a reusable SCSS mixin. The SCSS Mixin tab in this generator outputs a parameterized mixin with arguments for direction, width, height, and color — so you call @include triangle(up, 20px, 16px, #333) anywhere in your stylesheet rather than memorizing the border formula.

Animating CSS Triangles

Because CSS triangles are standard elements, they accept all standard CSS properties. Common animation patterns include:

These transitions perform at 60fps because they trigger only compositor-layer properties — no layout recalculation is involved.

Accessibility Considerations

CSS triangles are purely visual. If the triangle conveys meaningful information (e.g., a sort direction indicator), ensure the parent element has an appropriate aria-label or title attribute. For decorative triangles used as visual flourishes, apply aria-hidden="true" to keep screen readers uncluttered. The ::before pseudo-element approach is particularly good here since pseudo-elements are already ignored by most assistive technologies.