Outlines of elements

The concept of outlines is similar to using borders on elements. Do not confuse or replace borders with outlines, they have different meanings. Outlines are useful because they allow you to highlight an element in order to draw attention to it in some situation. Outlines are located outside the element, just outside its borders.

An outline in CSS 3 is represented by the outline property , although this property is shorthand for the following properties:

  • outline-color : outline color
  • outline-offset : outline offset
  • outline-style : outline style. It takes the same values ​​as border-style:
    1. none: no outline
    2. solid: outline as a regular line
    3. dashed: dashed line
    4. dotted: line as a sequence of points
    5. double: Outline in the form of two parallel lines
    6. outline-width : the thickness of the outline
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>Outline in CSS3</title>
    </head>
    <body>
        <div>Outline in CSS3</div>
    </body>
</html>
 


Using a property outline, this contour definition can be shortened as follows:


outline: red dashed 2px;