EDUCBA

EDUCBA

MENUMENU
  • Free Tutorials
  • Free Courses
  • Certification Courses
  • 600+ Courses All in One Bundle
  • Login

CSS Outline Property

By Chiranjan SahaChiranjan Saha

Home » Software Development » Software Development Tutorials » CSS Tutorial » CSS Outline Property

CSS Outline Property

Definition of CSS Outline Property

CSS outline property helps you to tweak the styling, width, coloring of the outline of an element of an HTML page with the use of CSS which is basically a line outside the area of border of an element to make the element limelight which may be required in your web page designing to bring user attention to that element. In this article,I will put you through the techniques with some illustrations that you can put in your code so that you can make some elements with the desired outline to make them stand out of the other elements of the HTML page.

Syntax and Parameters

CSS outline properties are basically useful to tweak the style and design of the element outline. CSS possesses the following properties in the outline which is present outside the border of an element: Outline Style, Color, width and offset.

Start Your Free Software Development Course

Web development, programming languages, Software testing & others

  1. Outline style defines the type of outline which is of many types:

Groove, double, dashed, inset, solid, dotted, ridge, outset

Syntax for Outline Style:

body
{
outline-style:<name of style>;
}

  1. Outline color defines the color of outline

Syntax for Outline Color:

body
{
outline-color:<name of color>;
}

  1. Outline width defines the thickness of outline

Syntax for Outline Width:

body
{
outline-width:<value of thickness>;
}

  1. Outline offset defines the gap between border and outline of an element

Syntax for Outline Offset:

body
{
outline-offset:<value of offset>;
}

How does Outline Property Work in CSS?

We require putting the property of the parameters of CSS outline utilizing basic syntax of CSS in HTML to achieve the desired outline styling.

In the next section, I will show many examples that will cover up each and every aspect of the demonstration of all outline properties of CSS in an HTML code. You should do hands on of those by yourself for more practical understanding.

Examples of CSS Outline Property

Following are the examples of css outline property are:

Example #1

In the first example, I will illustrate you with many cases of outline styling. In the output section, you will be able to see how one can achieve a different designed outline style as per their choice using various values of CSS outline style properties. It will be easier for you to understand if you refer to inline comments in code.

Code:

<!DOCTYPE html>
<html>
<head>
<style>
p.groove {outline-style: groove;} //defining many outline styling
p.double {outline-style: double;}
p.dashed {outline-style: dashed;}
p.inset {outline-style: inset;}
p.solid {outline-style: solid;}
p.dotted {outline-style: dotted;}
p.ridge {outline-style: ridge;}
p.outset {outline-style: outset;}
</style>
</head>
<body>
<h2>This is demonstration of property of outline-style</h2>
<p>Text without any outline</p>
<p class="groove">Text with a groove outline</p>
<p class="double">Text with a dual outline</p>
<p class="dashed">Text with a dashed borderline</p>
<p class="inset">Text with a outline which is inset</p>
<p class="solid">Text with a solid border</p>
<p class="dotted">Text with a dotted boundary</p>
<p class="ridge">Text with a ridge outline</p>
<p class="outset">Text with a outline which is outset</p>
</body>
</html>

Popular Course in this category
CSS Training (9 Courses, 9+ Projects)9 Online Courses | 9 Hands-on Projects | 61+ Hours | Verifiable Certificate of Completion | Lifetime Access
4.5 (5,416 ratings)
Course Price

View Course

Related Courses
Bootstrap Training (2 Courses, 6+ Projects)jQuery Training (8 Courses, 5 Projects)

Output:

CSS Outline Property-1.1

Example #2

Sometimes, the outline of an element also needs coloring as per design so that the page looks attractive and eye-catchy. In the second scenario, we will see some illustration of the coloring of the outline. We have shown here how you can put a different color as per choice to the outline of an element in the HTML page with the help of CSS outline properties.

Code:

<!DOCTYPE html>
<html>
<head>
<style>
h3
{
outline-style:solid;
outline-color:blue; //defining many outline coloring
}
h2
{
outline-style:dashed;
outline-color:green;
}
</style>
</head>
<body>
<h1>This is demonstration of property of outline color</h1>
<h2>Text with a colored dashed outline</h2>
<h3>Text with a colored solid outline</h3>
</body>
</html>

Output:

CSS Outline Property-1.2

Look at the above output. The dashed outline has green color and the solid one has a blue color. Think about how the coloring of the outline of an element gives it highlight with other elements in an HTML page which may be attractive for users.

Example #3

By default, there is a thickness value associated with the outline. But here, CSS gives you full flexibility to change that according to your need. In this example, I will demonstrate how you can tweak the thickness of the border of the outline as per your need. This will be useful in cases where some of the elements need to be enclosed with a thick border to bring more attention to the user as an important part of the web page.

Code:

<!DOCTYPE html>
<html>
<head>
<style>
h3
{
outline-width:2px;  //defining many outline width
outline-style:solid;
}
h2
{
outline-width:9px;
outline-style:dashed;
}
</style>
</head>
<body>
<h1>This is demonstration of property of outline width</h1>
<h2>Text with a thick  dashed outline</h2>
<h3>Text with a thin  solid outline</h3>
</body>
</html>

Output:

Output-1.3

Look at the above output. The dashed outline has a thick width compared to the solid outline with a thin width.

Example #4

Last but not least is the value of the offset. Offset defines the gap between the border and the outline of an element. Here, we have shown how you can increase or decrease the gap between the border and outline as per need. We have colored border and outline with different values so that it will easy to identify the gap between them.

Code:

<!DOCTYPE html>
<html>
<head>
<style>
h3
{
border:solid red 3px;
outline-style:solid;
outline-offset:6px; //defining many outline offset values
}
h2
{
border:solid red 2px;
outline-offset:2px;
outline-style:dashed;
}
</style>
</head>
<body>
<h1>This is demonstration of property of outline offset</h1>
<h2>Text with a dashed outline with thin offset </h2>
<h3>Text with a solid outline with thick offset gap</h3>
</body>
</html>

Output:

Output-1.4

Look at the above output carefully. The dashed outline has a lesser gap with its border, but the solid outline has more gap with its border.

Conclusion

The topic on “CSS outline property” is getting a conclusion here. In this topic, we have given so many examples which indicate mechanisms those ones can go through to use the values of many outline features of CSS coding of front end HTML page. This article can be considered one of a kind for the coders who are interested to make their carrier in front end web page development and design with CSS for their HTML page styling.

Recommended Articles

This is a guide to CSS Outline Property. Here we also discuss the definition and how does outline property work in css? along with a different example and its code implementation. You may also have a look at the following articles to learn more –

  1. CSS Row
  2. CSS page-break
  3. CSS content property
  4. CSS background-color

CSS Training (9 Courses, 9+ Projects)

9 Online Courses

9 Hands-on Projects

61+ Hours

Verifiable Certificate of Completion

Lifetime Access

Learn More

0 Shares
Share
Tweet
Share
Primary Sidebar
CSS Tutorial
  • CSS
    • Introduction To CSS
    • What is CSS?
    • Uses Of CSS
    • Advantages of CSS
    • Career In CSS
    • CSS Commands
    • Is Css Case Sensitive
    • CSS object-fit
    • Types of CSS Selectors
    • CSS Radio Button
    • CSS Attribute Selector
    • CSS first child of class
    • CSS Selector nth Child
    • CSS Parent Selector
    • CSS Child Selector
    • CSS Not Selector
    • CSS Descendant Selector
    • CSS Inline Style
    • Checkbox CSS
    • CSS Appearance
    • CSS Font Properties
    • CSS font-variant
    • CSS Pagination
    • CSS Table Styling
    • CSS Table Cell Padding
    • CSS Padding Color
    • CSS Text Formatting
    • CSS for Text-Shadow
    • CSS text-stroke
    • CSS text-indent
    • CSS Rotate Text
    • CSS Text Color
    • CSS Center Div
    • CSS Arrow
    • CSS Arrow Down
    • CSS offset
    • CSS Cursor
    • CSS Layout
    • CSS Grid Layout
    • Button in CSS
    • CSS Button Border
    • text-align in CSS
    • CSS Horizontal Align
    • CSS Position
    • CSS Box Sizing
    • CSS box-shadow
    • CSS Text Underline
    • CSS Text Outline
    • CSS Blinking Text
    • Text Decoration CSS
    • CSS Vertical Align
    • CSS Word Wrap
    • CSS Padding
    • CSS Font Color
    • CSS Color Generator
    • CSS Margin Right
    • CSS Margin Color
    • CSS Color Codes
    • CSS Color Transparent
    • CSS Color Chart
    • CSS Link Color
    • CSS z-index
    • CSS Curved Border
    • CSS Border Left
    • CSS left
    • CSS Gradient Generator
    • Radial Gradient in CSS
    • CSS Shape Generator
    • CSS Triangle Generator
    • CSS background-color
    • CSS Background Image
    • CSS background-clip
    • CSS background-blend-mode
    • CSS Drop Shadow
    • CSS line height
    • CSS line break
    • Sticky Footer CSS
    • CSS Header Design
    • CSS Border Style
    • CSS Border Generator
    • Sticky Sidebar CSS
    • CSS Transparent Border
    • CSS Border Radius
    • CSS translate
    • CSS transform
    • CSS 3D Transforms
    • CSS Text Transform
    • CSS Transition Effects
    • CSS Transition Property
    • CSS Animation Transition
    • Negative Margin CSS
    • CSS Navigation Bar
    • CSS Overflow
    • CSS overflow-wrap
    • CSS Lists
    • CSS list-style
    • CSS Order
    • CSS Box Model
    • CSS Inner Border
    • CSS Icon
    • Menu Icon CSS
    • CSS Multiple Borders
    • Opacity in CSS
    • CSS Float Right
    • CSS Clear Float
    • CSS clip
    • CSS disabled
    • CSS Border Padding
    • Border Images in CSS
    • CSS Visibility
    • CSS Validator
    • CSS Clearfix
    • CSS Counter
    • CSS Letter Spacing
    • CSS root
    • CSS zoom
    • CSS calc()
    • CSS.supports()
    • CSS Loader
    • Media Query CSS
    • CSS @keyframes
    • CSS @bottom
    • CSS page-break-after Property
    • CSS page-break
    • CSS Position Fixed
    • CSS skew()
    • CSS Row
    • CSS Masking
    • CSS Scrollbar
    • CSS Overlay
    • CSS Important
    • CSS Cursor Hand
    • CSS Inherit
    • CSS Position Relative
    • CSS Compressor
    • CSS tricks
    • CSS Outline Property
    • CSS Flexbox Properties
    • CSS flex-direction
    • CSS content property
    • CSS Typography
    • CSS Formatter
    • CSS nowrap
    • CSS Column
    • GridView CSS
    • CSS Viewport
    • CSS Minify
    • CSS Combinators
    • CSS in React
    • CSS Matrix 
    • CSS Pseudo Elements
    • CSS Pseudo Classes
    • CSS Pointer Events
    • CSS Resize
    • CSS Inheritance
    • CSS Interview Questions
    • Cheat Sheet CSS
  • CSS3
    • What is CSS3?
    • CSS3 Interview Questions
    • Cheat sheet CSS3
  • sass
    • How to Install SASS
    • SASS Interview Questions
    • What is Sass
    • SASS Comments
    • Sass Variables
    • SASS Import
    • SASS if else
    • SASS Nesting
    • SASS @each
    • SASS @at-root
    • SASS @extend
    • SASS @media
    • SASS @for
    • SASS Map
    • SASS Selectors
    • SASS Color Functions
    • SASS Mixins

Related Courses

CSS Training Course

Bootstrap Training Course

JQuery Training Course

Footer
About Us
  • Blog
  • Who is EDUCBA?
  • Sign Up
  • Corporate Training
  • Certificate from Top Institutions
  • Contact Us
  • Verifiable Certificate
  • Reviews
  • Terms and Conditions
  • Privacy Policy
  •  
Apps
  • iPhone & iPad
  • Android
Resources
  • Free Courses
  • Java Tutorials
  • Python Tutorials
  • All Tutorials
Certification Courses
  • All Courses
  • Software Development Course - All in One Bundle
  • Become a Python Developer
  • Java Course
  • Become a Selenium Automation Tester
  • Become an IoT Developer
  • ASP.NET Course
  • VB.NET Course
  • PHP Course

© 2020 - EDUCBA. ALL RIGHTS RESERVED. THE CERTIFICATION NAMES ARE THE TRADEMARKS OF THEIR RESPECTIVE OWNERS.

EDUCBA Login

Forgot Password?

EDUCBA
Free Software Development Course

Web development, programming languages, Software testing & others

*Please provide your correct email id. Login details for this Free course will be emailed to you
Book Your One Instructor : One Learner Free Class

Let’s Get Started

This website or its third-party tools use cookies, which are necessary to its functioning and required to achieve the purposes illustrated in the cookie policy. By closing this banner, scrolling this page, clicking a link or continuing to browse otherwise, you agree to our Privacy Policy

EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA
Free Software Development Course

Web development, programming languages, Software testing & others

*Please provide your correct email id. Login details for this Free course will be emailed to you

Special Offer - CSS Training (9 Courses, 9+ Projects) Learn More