A CSS border triangle renders as a trapezoid, a square, a flipped wedge, or a colored rectangle whenever the generator's zero-size element is missing width: 0 and height: 0, the colored border points the wrong way, or the supplied color is not a strict hash followed by six hexadecimal digits. The visible shape is painted entirely by borders on an element whose measurable content box is zero, which is why almost every wrong result comes back to one of three things: the geometry inputs you selected, a downstream style that overrides the generated class, or an accessibility assumption that does not match how the triangle is actually used.
The CSS Triangle Generator builds the shape from borders on a zero-size element, where transparent borders form the two slopes and one colored border points in the selected direction. The browser's native form controls block malformed input, and the pure generator independently rejects unsupported directions, malformed colors, decimals, and values outside the documented 10 to 300 pixel range. The live preview uses the same derived border declarations that are written to the CSS output, so when the preview looks correct and your page does not, the cause is almost always downstream rather than in the generator's logic.

Why a CSS Triangle Looks Wrong After Generation
The four-direction border triangle is unusually fragile because its visible area is painted entirely by borders on a zero-size element. Three things have to be true at once: the element has width: 0 and height: 0, two adjacent borders are transparent, and one border is the chosen color and points in the direction you actually want. Miss any of those and the shape becomes a trapezoid, a colored square, an inverted wedge, or a thin stripe. The geometry has no second chance inside the snippet, because there is no SVG, no canvas, no image file, and no pseudo-element library to fall back on.
The generator handles all three automatically. Its preview uses the same longhand border declarations it copies out, and it validates integer dimensions and a strict #RRGGBB color string before it writes any code. So when the copied snippet looks wrong in your project, the cause is almost always downstream: a parent rule that sets width or height on the div, a competing stylesheet that overrides the lizely-triangle class, or a layout context where the element is being measured differently than the preview was. Generation happens entirely in the current browser tab, so the page you are testing against is the only place these downstream rules can come from.
Direction and Border Setup Reference
Direction errors are the single most common cause of a flipped triangle. The generator maps four directions to specific borders, and reading the wrong border as the colored one is what flips the wedge. The mapping the generator writes is fixed and auditable, because the implementation explicitly serializes each longhand border property rather than relying on shorthand shortcuts:
| Selected direction | Colored border (the pointing edge) | Transparent borders (the slopes) | Colored border size |
|---|---|---|---|
| Up | Bottom | Left, Right | Equal to selected height |
| Down | Top | Left, Right | Equal to selected height |
| Left | Right | Top, Bottom | Equal to selected width |
| Right | Left | Top, Bottom | Equal to selected width |
For vertical triangles (up and down), the two transparent side borders add up to the selected width, and for horizontal triangles (left and right) the transparent top and bottom borders add up to the selected height. If the direction in your page does not match the direction you selected, the most likely cause is that you are reading the colored border from the wrong rule, or another stylesheet is rewriting one of the four border properties after the snippet loads.
A second common cause is a class-name collision. The generator names the div lizely-triangle by default. If your project already defines a rule with that name, the cascade will use whichever rule appears later in source order, which can reintroduce non-zero width or height and turn the triangle into a small rectangle. Renaming the class in both the CSS and the HTML snippet, and updating both outputs together, removes the collision.
Verify Dimensions, Odd Pixels, and Color Format
The generator accepts whole-number widths and heights from 10 through 300 pixels and a color in the form #RRGGBB, normalized to lowercase. If your pasted value does not preview at all, that is the upstream validation telling you the input was malformed; if your pasted value does preview but still looks wrong on the page, the dimensions themselves are the suspect.
Even totals split equally between the two transparent borders, so a 100 pixel up triangle uses border-left: 50px solid transparent, border-right: 50px solid transparent, and border-bottom: 100px solid #hex. Odd totals use floor and ceiling because Chromium can quantize two 20.5 pixel borders down to 20 pixels each, silently losing one pixel from the requested base. The generator instead writes, for example, border-left: 20px solid transparent and border-right: 21px solid transparent for a 41 pixel up triangle. That one-pixel asymmetry is intentional and preserves the requested total painted dimension rather than silently dropping a pixel.
Color is painted as an opaque border. Alpha colors, CSS variables, gradients, currentColor, wide-gamut syntax, and theme tokens are not generated by this focused tool. If your design system expects #rrggbbaa, rgb(...) with alpha, or var(--token), the literal HEX will still work, but you can replace it after copying with a trusted design token as long as you verify that transparent side borders remain transparent. Replacing the literal does not change the geometry, but it does not make the snippet theme-aware on its own.
How to Fix a Wrong CSS Triangle Result
- Open the CSS Triangle Generator and re-enter the direction, width, height, and six-digit HEX color you actually want. Confirm the live preview matches your target before copying.
- Copy CSS and HTML separately. The Copy buttons request clipboard permission individually, and a status line names the copied format; if browser policy denies clipboard access, both code blocks remain visible for manual selection and the page does not falsely report success.
- Inspect the destination page at the approximate size and background where the triangle will be used. Compare the on-page result to the generator preview at the same zoom and on the same backdrop, since rasterization varies with zoom and device pixel ratio.
- Rename lizely-triangle if that class would conflict with an existing stylesheet, and update both the CSS and the HTML output together so the rule and the class stay in sync.
- Preserve or replace the decorative aria-hidden="true" treatment as appropriate. For a decorative arrow or separator that conveys no information, the snippet is correct as-is; for a triangle that communicates state, direction, validation, navigation, or another meaning, remove aria-hidden from the div and add visible text or an accessible label to the surrounding interactive control instead.
- Test the triangle at 200 percent zoom, high contrast, forced colors, and on common mobile widths. The preview confirms border geometry; it does not confirm the complete accessibility or layout behavior of a destination component.
Address Jagged Edges, Theming, and Accessibility
Even a perfectly generated triangle can look wrong on the page. Diagonal border edges are smoothed by the browser's anti-aliasing, and different engines handle those edges differently: Safari renders them slightly sharper than Chrome, and Firefox falls somewhere between. There is no universal fix at the CSS border level, and the rasterization can also shift at different zoom levels and device pixel ratios. If you need a perfectly crisp diagonal, the CSS Triangle Generator cannot produce one; an SVG with an explicit viewBox will give more predictable edges.
Color and contrast are a second common source of a wrong-looking result. The chosen HEX color is painted as an opaque border, and the page does not know what sits behind it. A triangle next to text should be checked against light and dark themes rather than assumed to inherit sufficient contrast, and the Color Contrast Checker is a reliable way to confirm the combination against WCAG AA or AAA thresholds in your own environment.
Accessibility also covers the aria-hidden="true" attribute that ships in the HTML snippet. That attribute is appropriate for a purely decorative triangle that conveys no information. If the triangle communicates state, direction, validation, or navigation, the silent snippet is not enough: assistive technology will skip the shape, so screen reader users will miss the cue. In that case, keep the triangle hidden from assistive technology but add visible text or an accessible label to the surrounding semantic control rather than relying on the generated div alone.
Performance cost for one triangle is negligible, but hundreds of decorative elements can still increase DOM and paint work. Prefer one semantic control with a decorative shape over duplicated hidden controls so the markup stays small and assistive technology sees a single labeled element instead of many silent ones.
When a Border Triangle Cannot Be Fixed Inside the Generator
The generator is deliberately focused. It creates a simple solid triangle without SVG, canvas, an image file, or a pseudo-element library, and the implementation writes each longhand border explicitly so the geometry stays visible. That focus is what makes the snippet predictable, and it also defines the boundary of what can be fixed by re-running the tool.
A border triangle cannot directly create a rounded tip, curved edge, hollow shape, gradient fill, stroke, complex shadow, or arbitrary polygon. If your wrong-looking result is actually a wrong kind of result, you need a hollow chevron, a triangle with a 2 pixel outline, a soft drop shadow, or a triangle filled with a linear gradient, the generator is the wrong tool for the fix. Use SVG or clip-path instead, and confirm browser support in the intended environment before shipping. Background on the per-source border properties used by the snippet is documented in the MDN CSS backgrounds and borders guide and the CSS Backgrounds and Borders Level 3 specification.
The element's measurable content box is zero, while its painted borders occupy space. Layout, transforms, hit testing, outlines, overflow, and alignment can therefore behave less intuitively than an SVG with an explicit viewBox, which is why the preview only confirms border geometry and not the full destination layout. For a complete walk-through of the four-direction recipe and the zero-size trick, the CSS Create Triangle With Border guide goes step by step through the same approach the generator uses. For a quick checklist of missteps to avoid the next time you generate, Avoid These Mistakes When You Generate a CSS Triangle covers the same ground from the opposite direction.