Arrow to the bottom of the tooltip with CSS

In CSS, you can create a tooltip with an arrow pointing to the bottom by using the ::after pseudo-element to generate a triangular shape. This is achieved by manipulating border properties to create the arrow effect.

Syntax

.tooltip .tooltip-text::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 50%;
    margin-left: -border-width;
    border-width: size;
    border-style: solid;
    border-color: tooltip-color transparent transparent transparent;
}

Example

The following example demonstrates how to create a tooltip with an arrow pointing to the bottom −

<!DOCTYPE html>
<html>
<head>
<style>
    .mytooltip {
        position: relative;
        display: inline-block;
        margin-top: 80px;
        cursor: pointer;
        background-color: #f0f0f0;
        padding: 10px;
        border-radius: 4px;
    }
    
    .mytooltip .mytext {
        visibility: hidden;
        width: 140px;
        background-color: #333;
        color: #fff;
        text-align: center;
        border-radius: 6px;
        padding: 8px;
        position: absolute;
        z-index: 1;
        bottom: 100%;
        left: 50%;
        margin-left: -70px;
        margin-bottom: 10px;
        font-size: 14px;
    }
    
    .mytooltip .mytext::after {
        content: "";
        position: absolute;
        top: 100%;
        left: 50%;
        margin-left: -8px;
        border-width: 8px;
        border-style: solid;
        border-color: #333 transparent transparent transparent;
    }
    
    .mytooltip:hover .mytext {
        visibility: visible;
    }
</style>
</head>
<body>
    <div class="mytooltip">Hover over me
        <span class="mytext">Tooltip with bottom arrow!</span>
    </div>
</body>
</html>
A gray box with "Hover over me" text appears. When you hover over it, a dark tooltip with white text "Tooltip with bottom arrow!" appears above the box with a small triangular arrow pointing downward from the bottom center of the tooltip.

How It Works

The arrow is created using the ::after pseudo-element with these key properties:

  • content: "" − Creates an empty pseudo-element
  • border-color − Only the top border has color, others are transparent
  • border-width − Determines the arrow size
  • top: 100% − Positions the arrow at the bottom of the tooltip
  • left: 50% with margin-left − Centers the arrow horizontally

Conclusion

Creating a tooltip with a bottom-pointing arrow involves using CSS pseudo-elements and border manipulation. The ::after element generates the triangular arrow shape by utilizing transparent borders.

Updated on: 2026-03-15T12:29:03+05:30

915 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements