CSS Outline

CSS outline is a property that allows you to draw a line around the border of an element.

It is similar to the border property, but unlike borders, outlines do not take up space or affect the layout of the element. Outlines are often used to provide visual focus or highlight elements, especially in interactive elements like links and form fields.

Here's an overview of how to use the outline property:

The syntax for the outline property is as follows:

        
            selector {
    outline: outline-width outline-style outline-color;
}
        
    
Example
Try yourself
        
            button {
   outline: 2px solid red;
}

input:focus {
   outline: 3px dotted blue;
}

        
    

In the above example, buttons will have a solid red outline of 2 pixels width, and when an input element is focused, it will have a dotted blue outline of 3 pixels width.

It's important to note that the outline property can be used to create a visual effect around an element without affecting the layout. However, because it does not take up space, you might need to ensure there is enough padding or margin to prevent the outline from overlapping with the content or other elements.