- Services
- Case Studies
- Technologies
- NextJs development
- Flutter development
- NodeJs development
- ReactJs development
- About
- Contact
- Tools
- Blogs
- FAQ
CSS outline-style Customizing Element Outlines
Options include auto, none, dotted, dashed, solid, double, groove, ridge, inset, and outset.
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:
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 theoutline-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 asinherit
if inherited, otherwise acts asinitial
.
Example
Here’s how to use the outline-style
property in CSS:
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 theoutline-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 asinherit
if inherited, otherwise acts asinitial
.
Examples
Here are some examples to illustrate how the outline-style
property works:
Setting Outline Style to Auto
Setting Outline Style to Dotted and Dashed
Setting Outline Style to Solid and Double
Setting Outline Style to Groove and Ridge
Setting Outline Style to Inset and Outset
Formal Definition
The outline-style
property in CSS defines the style of an element’s outline. Here’s the formal definition:
Property Name | outline-style |
---|---|
Initial Value | none |
Applies To | All elements |
Inherited | No |
Computed Value | As specified |
Animation Type | By computed value type |
Formal Syntax
The formal syntax for the outline-style
property is:
Browser Compatibility
The outline-style
property is widely supported across all major web browsers, ensuring consistent and visually appealing designs.
Browser | Version | Release Date |
---|---|---|
Google Chrome | 1.0 | Dec 2008 |
Firefox | 1.5 | Nov 2005 |
IE / Edge | 8.0 | Mar 2009 |
Opera | 7.0 | Jan 2003 |
Safari | 1.2 | Feb 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.
Talk with CEO
We'll be right here with you every step of the way.
We'll be here, prepared to commence this promising collaboration.
Whether you're curious about features, warranties, or shopping policies, we provide comprehensive answers to assist you.