0% completed
CSS outlines add a line outside the element's border. They help highlight parts of your page without affecting the layout. Unlike borders, outlines do not occupy space. They are useful for focusing on elements or improving accessibility.
Using the outline property, you can quickly emphasize an element with a single line. This lesson covers how to set outline properties using both shorthand and individual properties.
Follow the code block below to set the outline in CSS:
/* Outline shorthand */ outline: outline-width outline-style outline-color; /* Individual outline properties */ outline-width: value; outline-style: value; outline-color: value;
Explanation:
2px
, medium
).solid
, dotted
, dashed
).red
, #00f
).In this example, we add a simple outline to a paragraph using the shorthand property. The outline makes the paragraph stand out without changing its layout.
Explanation:
In this example, we add an outline to a button when it receives focus. This technique improves accessibility by providing clear visual feedback when the button is active.
Explanation:
:focus
pseudo classes in the upcoming modules of the course.This lesson shows how to use CSS outlines to emphasize elements and improve interaction feedback. The outline property is a powerful tool for adding visual cues without altering the page layout.
.....
.....
.....