Languages
[Edit]
EN

CSS - difference between outline and border

3 points
Created by:
elmer
646

In this article, we would like to show you the difference between outline and border in CSS.

Quick answer:

An outline is a line drawn outside the element or element's border.

Outline doesn't affect on the web page layout, it means: outline doesn't shift area and sibling elements.

Outline and border visualization in CSS.
Outline and border visualization in CSS.

Practical examples

Edit

In the below example we compare three elements:

  • element with border,
  • element with outline
  • and  with both of them.

As we can see, outline creates additional layout neutral 'border' around elements.

 

See also

Edit
  1. CSS - border property example

  2. CSS - outline property example

References

Edit
  1. outline - CSS: Cascading Style Sheets | MDN
  2. border - CSS: Cascading Style Sheets | MDN

Alternative titles

  1. CSS - outline vs border
1
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join