Tillitsdone
down Scroll to discover

CSS outline-style Customizing Element Outlines

Learn how to use the CSS outline-style property to customize the appearance of an element's outline.

Options include auto, none, dotted, dashed, solid, double, groove, ridge, inset, and outset.
thumbnail

Introduction

The outline-style property in CSS lets you customize the appearance of an element’s outline. Unlike borders, outlines don’t take up space and are drawn outside the element’s border, making them perfect for adding emphasis without affecting layout.

This property offers various styles like dotted, dashed, solid, double, groove, ridge, inset, and outset. These styles help you create visually appealing and user-friendly designs.

Specification

The outline-style property is part of the CSS Basic User Interface Module Level 4 specification. It defines how an element’s outline looks, which is often used to indicate focus or attention.

The specification includes values like auto, none, dotted, dashed, solid, double, groove, ridge, inset, and outset. Each value provides a unique visual effect, helping you create customized and appealing outlines.

Syntax

The outline-style property in CSS defines the style of an element’s outline. Here’s the basic syntax:

outline-style: keyword-value;

Keyword Values

  • auto: The browser chooses a custom outline style.
  • none: No outline is shown.
  • dotted: The outline is a series of dots.
  • dashed: The outline is a series of short dashes.
  • solid: The outline is a single, continuous line.
  • double: The outline has two parallel lines.
  • groove: The outline looks carved into the page.
  • ridge: The outline looks raised from the page.
  • inset: The outline makes the element look embedded.
  • outset: The outline makes the element look raised out of the page.

Global Values

  • inherit: The element inherits the outline-style from its parent.
  • initial: Sets the property to its default value.
  • revert: Resets the property to the browser’s default.
  • revert-layer: Resets the property to the user-agent stylesheet value.
  • unset: Acts as inherit if inherited, otherwise acts as initial.

Example

Here’s how to use the outline-style property in CSS:

.element {
outline-style: dotted;
}

In this example, the element with the class .element will have a dotted outline.

Values

The outline-style property provides various values to customize the appearance of an element’s outline. Here’s a detailed explanation:

  • auto: The browser chooses a custom outline style.
  • none: No outline is shown.
  • dotted: The outline is a series of dots.
  • dashed: The outline is a series of short dashes.
  • solid: The outline is a single, continuous line.
  • double: The outline has two parallel lines.
  • groove: The outline looks carved into the page.
  • ridge: The outline looks raised from the page.
  • inset: The outline makes the element look embedded.
  • outset: The outline makes the element look raised out of the page.
  • initial: Sets the property to its default value.
  • inherit: The element inherits the outline-style from its parent.
  • revert: Resets the property to the browser’s default.
  • revert-layer: Resets the property to the user-agent stylesheet value.
  • unset: Acts as inherit if inherited, otherwise acts as initial.

Examples

Here are some examples to illustrate how the outline-style property works:

Setting Outline Style to Auto

<div class="auto">Outline Demo</div>
.auto {
outline-style: auto;
}
/* To make the Demo clearer */
* {
outline-width: 10px;
padding: 15px;
}

Setting Outline Style to Dotted and Dashed

<div class="dotted">
<p class="dashed">Outline Demo</p>
</div>
.dotted {
outline-style: dotted;
}
.dashed {
outline-style: dashed;
}
/* To make the Demo clearer */
* {
outline-width: 10px;
padding: 15px;
}

Setting Outline Style to Solid and Double

<div class="solid">
<p class="double">Outline Demo</p>
</div>
.solid {
outline-style: solid;
}
.double {
outline-style: double;
}
/* To make the Demo clearer */
* {
outline-width: 10px;
padding: 15px;
}

Setting Outline Style to Groove and Ridge

<div class="groove">
<p class="ridge">Outline Demo</p>
</div>
.groove {
outline-style: groove;
}
.ridge {
outline-style: ridge;
}
/* To make the Demo clearer */
* {
outline-width: 10px;
padding: 15px;
}

Setting Outline Style to Inset and Outset

<div class="inset">
<p class="outset">Outline Demo</p>
</div>
.inset {
outline-style: inset;
}
.outset {
outline-style: outset;
}
/* To make the Demo clearer */
* {
outline-width: 10px;
padding: 15px;
}

Formal Definition

The outline-style property in CSS defines the style of an element’s outline. Here’s the formal definition:

Property Nameoutline-style
Initial Valuenone
Applies ToAll elements
InheritedNo
Computed ValueAs specified
Animation TypeBy computed value type

Formal Syntax

The formal syntax for the outline-style property is:

outline-style = auto | none | dotted | dashed | solid | double | groove | ridge | inset | outset | inherit | initial | revert | revert-layer | unset;

Browser Compatibility

The outline-style property is widely supported across all major web browsers, ensuring consistent and visually appealing designs.

BrowserVersionRelease Date
Google Chrome1.0Dec 2008
Firefox1.5Nov 2005
IE / Edge8.0Mar 2009
Opera7.0Jan 2003
Safari1.2Feb 2004

See Also

To boost your CSS and web development skills, check out these useful resources:

  • [outline]WebsiteUrl: Learn about the shorthand property for setting all outline properties at once.
  • [outline-width]WebsiteUrl: Explore how to set the width of an element’s outline.
  • [outline-color]WebsiteUrl: Discover how to set the color of an element’s outline.
  • [outline-offset]WebsiteUrl: Understand how to set the space between an element’s outline and its edge.
  • [CSS Basic User Interface Module Level 4]WebsiteUrl: Dive into the official specification for more detailed information on the outline-style property.
  • [MDN Web Docs]WebsiteUrl: Access comprehensive guides and tutorials on CSS and web development.
icons/css-4.svg CSS Blogs
CSS3 is the latest version of Cascading Style Sheets, offering advanced styling features like animations, transitions, shadows, gradients, and responsive design.
icons/logo-tid.svg

Talk with CEO

Ready to bring your web/app to life or boost your team with expert Thai developers?
Contact us today to discuss your needs, and let’s create tailored solutions to achieve your goals. We’re here to help at every step!
🖐️ Contact us
Let's keep in Touch
Thank you for your interest in Tillitsdone! Whether you have a question about our services, want to discuss a potential project, or simply want to say hello, we're here and ready to assist you.
We'll be right here with you every step of the way.
Contact Information
rick@tillitsdone.com+66824564755
Find All the Ways to Get in Touch with Tillitsdone - We're Just a Click, Call, or Message Away. We'll Be Right Here, Ready to Respond and Start a Conversation About Your Needs.
Address
9 Phahonyothin Rd, Khlong Nueng, Khlong Luang District, Pathum Thani, Bangkok Thailand
Visit Tillitsdone at Our Physical Location - We'd Love to Welcome You to Our Creative Space. We'll Be Right Here, Ready to Show You Around and Discuss Your Ideas in Person.
Social media
Connect with Tillitsdone on Various Social Platforms - Stay Updated and Engage with Our Latest Projects and Insights. We'll Be Right Here, Sharing Our Journey and Ready to Interact with You.
We anticipate your communication and look forward to discussing how we can contribute to your business's success.
We'll be here, prepared to commence this promising collaboration.
Frequently Asked Questions
Explore frequently asked questions about our products and services.
Whether you're curious about features, warranties, or shopping policies, we provide comprehensive answers to assist you.