
- CSS Tutorial
- CSS - Home
- CSS - Introduction
- CSS - Syntax
- CSS - Inclusion
- CSS - Measurement Units
- CSS - Colors
- CSS - Backgrounds
- CSS - Fonts
- CSS - Text
- CSS - Images
- CSS - Links
- CSS - Tables
- CSS - Borders
- CSS - Margins
- CSS - Lists
- CSS - Padding
- CSS - Cursors
- CSS - Outlines
- CSS - Dimension
- CSS - Scrollbars
- CSS Advanced
- CSS - Visibility
- CSS - Positioning
- CSS - Layers
- CSS - Pseudo Classes
- CSS - Pseudo Elements
- CSS - @ Rules
- CSS - Text Effects
- CSS - Media Types
- CSS - Paged Media
- CSS - Aural Media
- CSS - Printing
- CSS - Layouts
- CSS - Validations
- CSS3 Tutorial
- CSS3 - Tutorial
- CSS3 - Rounded Corner
- CSS3 - Border Images
- CSS3 - Multi Background
- CSS3 - Color
- CSS3 - Gradients
- CSS3 - Shadow
- CSS3 - Text
- CSS3 - Web font
- CSS3 - 2d transform
- CSS3 - 3d transform
- CSS3 - Animation
- CSS3 - Multi columns
- CSS3 - User Interface
- CSS3 - Box Sizing
- CSS Responsive
- CSS - Responsive Web Design
- CSS References
- CSS - Questions and Answers
- CSS - Quick Guide
- CSS - References
- CSS - Color References
- CSS - Web browser References
- CSS - Web safe fonts
- CSS - Units
- CSS - Animation
- CSS Resources
- CSS - Useful Resources
- CSS - Discussion
Outlines Vs Borders in CSS
Outline doesn’t take up space and is displayed around the border if set. It is used for highlighting elements and we can’t specify whether individual sides should have an outline or not. Like borders, outline is not displayed by default. In some browsers, say Firefox, focused elements are displayed with a thin outline.
Borders can be customized to a greater extent. We style individual sides of a border and round their edges. Borders take up space and affect the box-sizing.
Syntax
The syntax of CSS border property is as follows −
Selector { border: /*value*/ outline: /*value*/ }
Example
The following examples illustrate CSS outline and border property −
<!DOCTYPE html> <html> <head> <style> p { display: flex; float: left; margin: 20px; padding: 12px; width: 30%; outline: thin dotted; background-color: lavender; } p + p { width: 250px; outline: none; border: outset; } </style> </head> <body> <h2>Learning is fun</h2> <p>Java is a high-level programming language originally developed by Sun Microsystems and released in 1995.</p> <p>Java runs on a variety of platforms, such as Windows, Mac OS, and the various versions of UNIX. Java is a MUST for students and working professionals to become a great Software Engineer specially when they are working in Software Development Domain</p> </body> </html>
Output
This gives the following output −
Example
<!DOCTYPE html> <html> <head> <style> article { margin: auto; width: 70%; outline: thick double; background-color: lightgoldenrodyellow; } h3 { border: inset; } </style> </head> <body> <h3>Kotlin Tutorial</h3> <article>Kotlin is a programming language introduced by JetBrains, the official designer of the most intelligent Java IDE, named Intellij IDEA. This is a strongly statically typed language that runs on JVM. In 2017, Google announced Kotlin is an official language for android development. Kotlin is an open source programming language that combines object-oriented programming and functional features into a unique platform.</article> </body> </html>
Output
This gives the following output −
- Related Articles
- Effect of Color Property on Borders and Outlines in CSS
- Collapsing Table Borders in CSS
- Adding Borders to Tables in CSS
- Collapsing Table Borders using CSS
- Add borders to pagination using CSS
- Adding Borders to Tables using CSS
- Create a link button with borders using CSS
- How to create and style borders using CSS?
- Set the color of the four borders using CSS
- How to eliminate blue borders around linked images using CSS?
- Em vs Rem units in CSS?
- CSS Visibility vs Display
- Tailwind CSS Vs Bootstrap
- What Are the Digital Marketing Outlines?
- Add rounded borders to first and last link in the pagination using CSS

Advertisements