Set outline style as a solid single line with CSS

The CSS outline-style property with the value solid creates a solid single line outline around an element. This outline appears outside the element's border and does not affect the layout or positioning of other elements.

Syntax

selector {
    outline-style: solid;
}

Example

The following example shows how to create a solid outline around a paragraph element −

<!DOCTYPE html>
<html>
<head>
<style>
    .solid-outline {
        outline-width: 3px;
        outline-style: solid;
        outline-color: #333;
        padding: 15px;
        margin: 20px;
        background-color: #f0f0f0;
    }
</style>
</head>
<body>
    <p class="solid-outline">
        This text has a 3px solid outline around it.
    </p>
</body>
</html>
A paragraph with gray background and a solid black outline (3px thick) appears on the page. The outline surrounds the entire element including its padding.

Conclusion

The outline-style: solid property creates a continuous single line outline around elements. Unlike borders, outlines don't take up space and are ideal for focus indicators and highlighting elements.

Updated on: 2026-03-15T11:21:22+05:30

132 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements