- 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:
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 theoutline-stylefrom 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 asinheritif inherited, otherwise acts asinitial.
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 theoutline-stylefrom its parent.revert: Resets the property to the browser’s default.revert-layer: Resets the property to the user-agent stylesheet value.unset: Acts asinheritif inherited, otherwise acts asinitial.
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 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:
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.
| 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-styleproperty. - [MDN Web Docs]WebsiteUrl: Access comprehensive guides and tutorials on CSS and web development.
สร้างเว็บไซต์ 1 เว็บ ต้องใช้งบเท่าไหร่? เจาะลึกทุกองค์ประกอบ website development cost อยากสร้างเว็บไซต์แต่ไม่มั่นใจในเรื่องของงบประมาณ อ่านสรุปเจาะลึกตั้งแต่ดีไซน์, ฟังก์ชัน และการดูแล พร้อมตัวอย่างงบจริงจาก Till it’s done ที่แผนชัด งบไม่บานปลายแน่นอน
Next.js สอน 14 ขั้นตอนเบื้องต้น: สร้างโปรเจกต์แรกใน 30 นาที เริ่มต้นกับ Next.js ใน 14 ขั้นตอนเพียงแค่ 30 นาที พร้อม SSR/SSG และ API Routes ด้วยตัวอย่างโค้ดง่าย ๆ อ่านต่อเพื่อสร้างโปรเจ็กต์แรกได้ทันทีที่นี่
วิธีสมัคร Apple Developer Account เพื่อนำแอปขึ้น App Store ทีละขั้นตอน อยากปล่อยแอปบน App Store ระดับโลก มาอ่านคู่มือสมัคร Apple Developer Account พร้อมเคล็ดลับ TestFlight และวิธีอัปโหลดที่ง่ายในบทความเดียวนี้ได้เลย
TypeScript Interface คืออะไร? อธิบายพร้อมวิธีใช้และข้อแตกต่างจาก Type เรียนรู้วิธีใช้ TypeScript Interface เพื่อสร้างโครงสร้างข้อมูลที่ปลอดภัยและเข้าใจง่าย พร้อมเปรียบเทียบข้อดีข้อแตกต่างกับ Type ที่คุณต้องรู้ ถูกรวมเอาไว้ในบทความนี้แล้ว
Material-UI (MUI) คืออะไร อยากสร้าง UI สวยงามและเป็นมืออาชีพในเวลาอันรวดเร็วใช่ไหม มาทำความรู้จักกับ Material-UI (MUI) ที่ช่วยให้คุณพัฒนาแอปพลิเคชันบน React ได้ง่ายและดูดีในทุกอุปกรณ์
เปรียบเทียบ 3 วิธีติดตั้ง install node js บน Ubuntu: NVM vs NodeSource vs Official Repo แบบไหนดีที่สุด? เรียนรู้วิธีติดตั้ง Node.js บน Ubuntu ด้วย NVM, NodeSource หรือ Official Repo เลือกวิธีที่เหมาะกับความต้องการของคุณ พร้อมเปรียบเทียบ เพื่อการพัฒนาที่มีประสิทธิภาพ! 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.