CSS Font Border (original) (raw)

Last Updated : 5 Jun, 2026

CSS Font Border is a technique used to add an outline around text, improving its visibility, readability, and appearance. It helps text stand out against images, colorful backgrounds, or complex layouts, making it more attractive and easier to read.

Techniques to Create Font Border

While CSS doesn’t have a built-in property for font borders, there are a few techniques that can create the same effect. Below are the most effective methods we can use to outline text in your designs.

1. Using text-shadow

The most widely supported and flexible way to create a font border is by layering multiple text-shadow values. This method works across all major browsers and lets you control the direction, blur, and color of the shadows.

**Syntax:

text-shadow: h-shadow v-shadow blur-radius color;

CSS Font Border - text-shadow Example
<style>
    body {
        background: linear-gradient(135deg, #2c3e50, #3498db);
        margin: 0;
        padding: 0;
        font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    }
    .text-border {
        text-align: center;
        padding: 150px 20px;
        font-size: 72px;
        font-weight: 900;
        color: #ffffff;
        text-shadow:
            -2px -2px 0 #000,
            2px -2px 0 #000,
            -2px 2px 0 #000,
            2px 2px 0 #000,
            -3px 0px 0 #000,
            3px 0px 0 #000,
            0px -3px 0 #000,
            0px 3px 0 #000;
    }
</style>
CSS Font Border

`

Neon Glow Effect Using text-shadow: The text-shadow property can also be used to create a vibrant neon glow effect, not just borders.

html `

<style>
    .neon-text {
        font-size: 48px;
        color: #fff;
        text-shadow:
            0 0 5px #0ff,
            0 0 10px #0ff,
            0 0 20px #0ff,
            0 0 40px #0ff,
            0 0 80px #0ff;
        background-color: #000;
        padding: 20px;
        text-align: center;
    }
</style>
Neon Glow Effect

`

**Property Values of text-shadow : text-shadow property accepts a lot of values, some of them are mentioned in the table below.

Property Value Description
h-shadow Sets the horizontal shadow around the text.
v-shadow Sets the vertical shadow around the text.
blur-radius Sets the blur radius around the text shadow.
color Sets the color of the text shadow.
none Does not set anything around the text (no shadow).
initial Sets the text shadow to its default initial value.
inherit Inherits the property values from its parent element.

**Note: The text-shadow property returns a shadow effect around the text, which can be used to create a simulated font border or outline.

2. Using -webkit-text-stroke

A more precise and powerful method for adding text borders is the -webkit-text-stroke property. This method actually draws an outline around each letter, making it look clean, bold, and sharp.

**Syntax:

****-webkit-text-stroke:** width color;

<style>
    .stroked-text {
        font-size: 48px;
        color: white;
        -webkit-text-stroke: 2px black;
    }
</style>

Stroked Text Example

`

3. Using SVG Text for Advanced Effects

SVG is particularly useful when you need your text to remain sharp on all screen sizes and resolutions, making it ideal for logos, banners, or any design element that demands pixel-perfect quality.

index.html `

<style>
    body {
        background-color: #2c3e50;
        margin: 0;
        padding: 0;
        display: flex;
        justify-content: center;
        align-items: center;
        height: 100vh;
    }
</style>
CSS Font Border

`

Best Practices for Using CSS Font Borders